On Wed, Nov 23, 2011 at 11:13:47 +0100, Michal Privoznik wrote: > Latest nwfilter patch ad6c67cf introduced uninitialized return > value. This was spotted by 4.6.2 gcc. > --- > src/nwfilter/nwfilter_learnipaddr.c | 12 +++++++----- > 1 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/src/nwfilter/nwfilter_learnipaddr.c > b/src/nwfilter/nwfilter_learnipaddr.c > index 675ef5b..2e373a6 100644 > --- a/src/nwfilter/nwfilter_learnipaddr.c > +++ b/src/nwfilter/nwfilter_learnipaddr.c > @@ -323,7 +323,7 @@ virNWFilterDeregisterLearnReq(int ifindex) { > static int > virNWFilterAddIpAddrForIfname(const char *ifname, char *addr) > { > - int ret; > + int ret = -1; > virNWFilterVarValuePtr val; > > virMutexLock(&ipAddressMapLock); > @@ -333,16 +333,18 @@ virNWFilterAddIpAddrForIfname(const char *ifname, char > *addr) > val = virNWFilterVarValueCreateSimple(addr); > if (!val) { > virReportOOMError(); > - ret = -1; > - goto err_exit; > + goto cleanup; > } > ret = virNWFilterHashTablePut(ipAddressMap, ifname, val, 1); > + goto cleanup; > } else { > if (virNWFilterVarValueAddValue(val, addr) < 0) > - ret = -1; > + goto cleanup; > } > > -err_exit: > + ret = 0; > + > +cleanup: > virMutexUnlock(&ipAddressMapLock); > > return ret;
ACK, although this is still not completely right, since virNWFilterHashTablePut returns 1 on error, while this function wants to return -1 on error. But it's virNWFilterHashTablePut that needs to be fixed to return -1 and after that, no additional work is needed in the function you're touching with this patch. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list