[libvirt] [PATCH v2] nwfilter: Initialize virNWFilterAddIpAddrForIfname return variable

Thanks for trying to fix this. This one tries to address Jiri's concern about the return value from virNWFilterHashTablePut with a not to fix it in the future. Latest nwfilter patch ad6c67cf introduced uninitialized return value. This was spotted by 4.6.2 gcc. --- src/nwfilter/nwfilter_learnipaddr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c =================================================================== --- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c +++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c @@ -323,7 +323,7 @@ virNWFilterDeregisterLearnReq(int ifinde static int virNWFilterAddIpAddrForIfname(const char *ifname, char *addr) { - int ret; + int ret = -1; virNWFilterVarValuePtr val; virMutexLock(&ipAddressMapLock); @@ -333,16 +333,21 @@ virNWFilterAddIpAddrForIfname(const char val = virNWFilterVarValueCreateSimple(addr); if (!val) { virReportOOMError(); - ret = -1; - goto err_exit; + goto cleanup; } ret = virNWFilterHashTablePut(ipAddressMap, ifname, val, 1); + /* FIXME: fix when return code of virNWFilterHashTablePut changes */ + if (ret) + ret = -1; + goto cleanup; } else { if (virNWFilterVarValueAddValue(val, addr) < 0) - ret = -1; + goto cleanup; } -err_exit: + ret = 0; + +cleanup: virMutexUnlock(&ipAddressMapLock); return ret;

On 11/23/2011 05:15 AM, Stefan Berger wrote:
Thanks for trying to fix this. This one tries to address Jiri's concern about the return value from virNWFilterHashTablePut with a not to fix it in the future.
Latest nwfilter patch ad6c67cf introduced uninitialized return value. This was spotted by 4.6.2 gcc. --- src/nwfilter/nwfilter_learnipaddr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Quite a bit of traffic on this one :) Looks like Dan already pushed a shorter stop-gap patch, but ACK if you'd like to push this one as a more complete version. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 11/23/2011 07:31 AM, Eric Blake wrote:
On 11/23/2011 05:15 AM, Stefan Berger wrote:
Thanks for trying to fix this. This one tries to address Jiri's concern about the return value from virNWFilterHashTablePut with a not to fix it in the future.
Latest nwfilter patch ad6c67cf introduced uninitialized return value. This was spotted by 4.6.2 gcc. --- src/nwfilter/nwfilter_learnipaddr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) Quite a bit of traffic on this one :)
Looks like Dan already pushed a shorter stop-gap patch, but ACK if you'd like to push this one as a more complete version.
I pushed this one now.
participants (2)
-
Eric Blake
-
Stefan Berger