[libvirt] [PATCH] bridge: Fix uninitialized variable

--- Pushed under the build-breaker rule. src/util/bridge.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/bridge.c b/src/util/bridge.c index dcd3f39..81a043c 100644 --- a/src/util/bridge.c +++ b/src/util/bridge.c @@ -676,7 +676,7 @@ brAddInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1; @@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1; -- 1.7.3.4

On 12/23/2010 05:14 PM, Jiri Denemark wrote:
--- Pushed under the build-breaker rule.
src/util/bridge.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/bridge.c b/src/util/bridge.c index dcd3f39..81a043c 100644 --- a/src/util/bridge.c +++ b/src/util/bridge.c @@ -676,7 +676,7 @@ brAddInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!? Thanks for catching it! (Beyond that - what options are you using that it didn't build? I can't imagine that you actually encountered this at runtime, since in practice the addresses passed to these functions have already been qualified, so the only real-world time this would happen is if you were out of memory).

@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!?
Thanks for catching it!
(Beyond that - what options are you using that it didn't build?
I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that. Jirka

On 01/03/2011 04:19 AM, Jiri Denemark wrote:
@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!?
Thanks for catching it!
(Beyond that - what options are you using that it didn't build? I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that.
Right. I do that too, and never saw an error. Your compiler must be warning on more things than mine. Here's my build commandline (copied from Jim nearly 2 years ago, and pretty much unchanged since): ./autogen.sh --with-qemu-user=qemu --with-qemu-group=qemu --enable-compile-warnings=error --prefix=/usr --libdir=/usr/lib64 --disable-nls CFLAGS="-g -Wformat -Wformat-security -Winit-self -Wall -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Winline -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -Dlint"

On 04/01/2011, at 12:11 AM, Laine Stump wrote:
On 01/03/2011 04:19 AM, Jiri Denemark wrote:
@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!?
Thanks for catching it!
(Beyond that - what options are you using that it didn't build? I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that.
Right. I do that too, and never saw an error. Your compiler must be warning on more things than mine. Here's my build commandline (copied from Jim nearly 2 years ago, and pretty much unchanged since):
./autogen.sh --with-qemu-user=qemu --with-qemu-group=qemu --enable-compile-warnings=error --prefix=/usr --libdir=/usr/lib64 --disable-nls CFLAGS="-g -Wformat -Wformat-security -Winit-self -Wall -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Winline -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -Dlint"
As a general thought, would there be benefit in us updating the libvirt.org "Compiling" page to show useful arguments like these for development?

于 2011年01月04日 17:13, Justin Clift 写道:
On 04/01/2011, at 12:11 AM, Laine Stump wrote:
On 01/03/2011 04:19 AM, Jiri Denemark wrote:
@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!?
Thanks for catching it!
(Beyond that - what options are you using that it didn't build? I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that.
Right. I do that too, and never saw an error. Your compiler must be warning on more things than mine. Here's my build commandline (copied from Jim nearly 2 years ago, and pretty much unchanged since):
./autogen.sh --with-qemu-user=qemu --with-qemu-group=qemu --enable-compile-warnings=error --prefix=/usr --libdir=/usr/lib64 --disable-nls CFLAGS="-g -Wformat -Wformat-security -Winit-self -Wall -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Winline -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -Dlint"
As a general thought, would there be benefit in us updating the libvirt.org "Compiling" page to show useful arguments like these for development?
That will be nice, at least I didn't use these much options when compiling before, :-) Regards Osier

On 01/04/2011 04:24 AM, Osier Yang wrote:
于 2011年01月04日 17:13, Justin Clift 写道:
On 04/01/2011, at 12:11 AM, Laine Stump wrote:
On 01/03/2011 04:19 AM, Jiri Denemark wrote:
@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!?
Thanks for catching it!
(Beyond that - what options are you using that it didn't build? I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that.
Right. I do that too, and never saw an error. Your compiler must be warning on more things than mine. Here's my build commandline (copied from Jim nearly 2 years ago, and pretty much unchanged since):
./autogen.sh --with-qemu-user=qemu --with-qemu-group=qemu --enable-compile-warnings=error --prefix=/usr --libdir=/usr/lib64 --disable-nls CFLAGS="-g -Wformat -Wformat-security -Winit-self -Wall -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Winline -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -Dlint"
As a general thought, would there be benefit in us updating the libvirt.org "Compiling" page to show useful arguments like these for development?
That will be nice, at least I didn't use these much options when compiling before, :-)
Full disclosure - I'm not sure of the usefulness of every one of these options. I have (at least partly) just been blindly following Jim Meyering's advice (which is usually pretty good :-)

I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that.
Right. I do that too, and never saw an error. Your compiler must be warning on more things than mine. Here's my build commandline (copied from Jim nearly 2 years ago, and pretty much unchanged since):
./autogen.sh --with-qemu-user=qemu --with-qemu-group=qemu --enable-compile-warnings=error --prefix=/usr --libdir=/usr/lib64 --disable-nls CFLAGS="-g -Wformat -Wformat-security -Winit-self -Wall -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Winline -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -Dlint"
My command line is just autogen.sh --system --enable-compile-warnings=error --enable-debug=yes or if I need to debug something more seriously, I use autogen.sh --system --enable-compile-warnings=error --enable-debug=yes CFLAGS=-g to get rid of the default -O2. I noticed you don't have -O2 in your CFLAGS, which might be the issue here. While -g is much better than -g -O2 when you actually start debugging, gcc does not issue some warnings when it compiles without optimizations :-( Jirka

On 01/04/2011 06:37 AM, Jiri Denemark wrote:
I noticed you don't have -O2 in your CFLAGS, which might be the issue here. While -g is much better than -g -O2 when you actually start debugging, gcc does not issue some warnings when it compiles without optimizations :-(
That probably explains it. Yeah, that definitely is a bummer - it would be nice to be able to use the same flags for runtime debug as well as compile-time checking. I guess I'll have to put an arg into my configure script, because I don't want to be missing things like this :-/

On Mon, Jan 03, 2011 at 08:11:57AM -0500, Laine Stump wrote:
On 01/03/2011 04:19 AM, Jiri Denemark wrote:
@@ -715,7 +715,7 @@ brDelInetAddress(brControl *ctl ATTRIBUTE_UNUSED, virSocketAddr *addr, unsigned int prefix) { - virCommandPtr cmd; + virCommandPtr cmd = NULL; char *addrstr; int ret = -1;
Wow! How did I miss *that*?!?
Thanks for catching it!
(Beyond that - what options are you using that it didn't build? I always build with --enable-compile-warnings=error so any compiler warning results in build failure. No special options beyond that.
Right. I do that too, and never saw an error. Your compiler must be warning on more things than mine. Here's my build commandline (copied from Jim nearly 2 years ago, and pretty much unchanged since):
./autogen.sh --with-qemu-user=qemu --with-qemu-group=qemu --enable-compile-warnings=error --prefix=/usr --libdir=/usr/lib64 --disable-nls CFLAGS="-g -Wformat -Wformat-security -Winit-self -Wall -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Winline -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -Dlint"
All those CFLAGS except for '-Dlint' are set by --enable-compile-warnings so is redundant. You can also use --system instead of --prefix and --libdir, which ensures you should build with a RPM-compatible prefix Daniel
participants (5)
-
Daniel P. Berrange
-
Jiri Denemark
-
Justin Clift
-
Laine Stump
-
Osier Yang