[libvirt] [PATCH] qemu: fix uninitialized variable warning

Eric Blake eblake at redhat.com
Mon May 2 15:27:04 UTC 2011


On 05/02/2011 03:10 AM, Christophe Fergeau wrote:
> This commit fixes
> qemu/qemu_driver.c: In function 'qemuDomainModifyDeviceFlags':
> qemu/qemu_driver.c:4041:8: warning: 'ret' may be used uninitialized in this
> function [-Wuninitialized]
> qemu/qemu_driver.c:4013:9: note: 'ret' was declared here
> 
> The variable is set to -1 so that the error paths are taken when the code
> to set it didn't get a chance to run. Without initializing it, we could
> return some an undefined value from this function.
> 
> While I was at it, I made a trivial whitespace change in the same function
> to improve readability.
> ---
>  src/qemu/qemu_driver.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

ACK and pushed.

I _really_ hate that gcc can only detect uninitialized variable usage
like this only at -O2.  I often build with -O0 because it's easier to
use gdb with, but it means I lose compiler error checking.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110502/1bef927d/attachment-0001.sig>


More information about the libvir-list mailing list