[libvirt] [PATCH 07/33] Remove usage of brctl command line tool

Daniel P. Berrange berrange at redhat.com
Wed Nov 9 16:53:30 UTC 2011


On Tue, Nov 08, 2011 at 09:48:34AM -0500, Stefan Berger wrote:
> On 11/03/2011 01:30 PM, Daniel P. Berrange wrote:
> >From: "Daniel P. Berrange"<berrange at redhat.com>
> >
> >Convert the virNetDevBridgeSetSTP and virNetDevBridgeSetSTPDelay
> >to use ioctls instead of spawning brctl.
> >
> >Implement the virNetDevBridgeGetSTP and virNetDevBridgeGetSTPDelay
> >methods which were declared in the header but never existed
> >
> >* src/util/bridge.c: Convert to use bridge ioctls instead of brctl
> >---
> >  configure.ac      |    2 -
> >  libvirt.spec.in   |    2 -
> >  src/util/bridge.c |  199 +++++++++++++++++++++++++++++++++++++++++++++++++----
> >  3 files changed, 184 insertions(+), 19 deletions(-)

> >@@ -817,22 +924,54 @@ cleanup:
> >  int virNetDevBridgeSetSTPDelay(const char *brname,
> >                                 int delay)
> >  {
> >-    virCommandPtr cmd;
> >+    int fd = -1;
>
> Also applicable for the other patches, the initialization to -1
> doesn't seem necessary.

I prefer to be overly cautious when declaring file descriptor variables.
Even though the current code will always initialize FD, someone might
come along later and refactor the method, resulting in code which needs
the -1 initialization at declaration.  GCC is not entirely reliable at
detecting use of uninitialized variables.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list