[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 1/3] build: fix "missing initializer" error in qemu_process.c



On 03/26/2012 12:53 PM, Laine Stump wrote:
> Found when attempting to build on Fedora 17 alpha with:
> 
>    ./autogen.sh --system --enable-compile-warnings=error
> 
> (this same build command works without problem on Fedora 16). Since
> the consumer of the qemuProcessReconnectData doesn't assume that the
> other fields of the struct are initialized (although it uses them
> internally), the simpler solution is to just switch to C99-style
> struct initialization (which doesn't require specification of all
> fields).
> ---
>  src/qemu/qemu_process.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 0e768fe..ce3bd27 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -3255,7 +3255,7 @@ error:
>  void
>  qemuProcessReconnectAll(virConnectPtr conn, struct qemud_driver *driver)
>  {
> -    struct qemuProcessReconnectData data = {conn, driver};
> +    struct qemuProcessReconnectData data = {.conn = conn, .driver = driver};

Both styles guarantee that the other fields are actually used
0-initialized (not uninitialized); but since only the latter shuts up
the compiler:

ACK.

It really bothers me that gcc has some warnings that only trigger at
-O2, but not at -O0 -g, but that's not your fault :)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]