[libvirt] [PATCH] nwfilter_conf.c: don't test an uninitialized local variable

I've just run the code through clang, and it spotted a few new problems. Here's one:
From 4c848787c8268e37db9a1d0754b8fcd8e5774f73 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Mon, 29 Mar 2010 17:34:32 +0200 Subject: [PATCH] nwfilter_conf.c: don't test an uninitialized local variable
* src/conf/nwfilter_conf.c (virNWIPAddressFormat): Do not use "i" uninitialized. --- src/conf/nwfilter_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index e82aae6..f673e69 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2423,7 +2423,7 @@ virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr) ipaddr->addr.ipv4Addr[2], ipaddr->addr.ipv4Addr[3]); } else { - int i; + unsigned int i = 0; int dcshown = 0, in_dc = 0; unsigned short n; while (i < 8) { -- 1.7.0.3.448.g82eeb

On 03/29/2010 09:35 AM, Jim Meyering wrote:
I've just run the code through clang, and it spotted a few new problems. Here's one: } else { - int i; + unsigned int i = 0; int dcshown = 0, in_dc = 0; unsigned short n; while (i < 8) {
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

libvir-list-bounces@redhat.com wrote on 03/29/2010 11:35:31 AM:
I've just run the code through clang, and it spotted a few new problems. Here's one:
From 4c848787c8268e37db9a1d0754b8fcd8e5774f73 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Mon, 29 Mar 2010 17:34:32 +0200 Subject: [PATCH] nwfilter_conf.c: don't test an uninitialized local
variable
* src/conf/nwfilter_conf.c (virNWIPAddressFormat): Do not use "i" uninitialized. --- src/conf/nwfilter_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index e82aae6..f673e69 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2423,7 +2423,7 @@ virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr) ipaddr->addr.ipv4Addr[2], ipaddr->addr.ipv4Addr[3]); } else { - int i; + unsigned int i = 0; int dcshown = 0, in_dc = 0; unsigned short n; while (i < 8) { -- 1.7.0.3.448.g82eeb
Thanks so much for looking at this. I do have a patch following Daniel V.'s suggestion to get rid of the home-cooked IPv6 parser/print function and it will do away with that code section. Regards, Stefan
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Eric Blake
-
Jim Meyering
-
Stefan Berger