]> xenbits.xensource.com Git - libvirt.git/commit
virsh: Resolve Coverity DEADCODE
authorJohn Ferlan <jferlan@redhat.com>
Thu, 4 Sep 2014 15:31:08 +0000 (11:31 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Sep 2014 12:03:37 +0000 (08:03 -0400)
commitdaf27d4d82bd391f426f7b4d09df426df2b36755
tree3b6133593a87d2d21fb6e681cb43439b6bf848ce
parentf832aa32221d841360572d4279defa11a04efbcb
virsh: Resolve Coverity DEADCODE

Since 0766783abbe8bbc9ea686c2c3149f4c0ac139e19

Coverity complains that the EDIT_FREE definition results in DEADCODE.

As it turns out with the change to use the EDIT_FREE macro the call to
vir*Free() wouldn't be necessary nor would it happen...

Prior code to above commitid would :

  vir*Ptr foo = NULL;
  ...
  foo = vir*GetXMLDesc()
  ...
  vir*Free(foo);
  foo = vir*DefineXML()
  ...

And thus the free was needed.  With the change to use EDIT_FREE the
same code changed to:

  vir*Ptr foo = NULL;
  vir*Ptr foo_edited = NULL;
  ...
  foo = vir*GetXMLDesc()
  ...
  if (foo_edited)
      vir*Free(foo_edited);
  foo_edited = vir*DefineXML()
  ...

However, foo_edited could never be set in the code path - even with
all the goto's since the only way for it to be set is if vir*DefineXML()
succeeds in which case the code to allow a retry (and thus all the goto's)
never leaves foo_edited set

All error paths lead to "cleanup:" which causes both foo and foo_edited
to call the respective vir*Free() routines if set.

Signed-off-by: John Ferlan <jferlan@redhat.com>
tools/virsh-domain.c
tools/virsh-edit.c
tools/virsh-interface.c
tools/virsh-network.c
tools/virsh-nwfilter.c
tools/virsh-pool.c
tools/virsh-snapshot.c