]> xenbits.xensource.com Git - libvirt.git/commitdiff
interface: drop dead code
authorEric Blake <eblake@redhat.com>
Tue, 2 Aug 2011 22:08:05 +0000 (16:08 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 2 Aug 2011 22:39:01 +0000 (16:39 -0600)
Coverity detected that ifaceGetNthParent had already dereferenced
'nth' prior to the conditional; all callers already complied with
passing a non-NULL pointer so make this part of the contract.

* src/util/interface.h (ifaceGetNthParent): Add annotations.
* src/util/interface.c (ifaceGetNthParent): Drop useless null check.

src/util/interface.c
src/util/interface.h

index f5eecfb8b65cfcb504c05805ddf150de46359ac2..8b4522b306378914c2b55bf4c5a8491e2f7c2be8 100644 (file)
@@ -1060,8 +1060,7 @@ ifaceGetNthParent(int ifindex, const char *ifname, unsigned int nthParent,
         i++;
     }
 
-    if (nth)
-        *nth = i - 1;
+    *nth = i - 1;
 
     return rc;
 }
index 9647653947089a4109e4847138449cc27958234b..47c0eb0a9b93848c426b9e4536f51dc25699a658 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * interface.h: interface helper APIs for libvirt
  *
+ * Copyright (C) 2011 Red Hat, Inc.
  * Copyright (C) 2010 IBM Corporation, Inc.
  *
  * See COPYING.LIB for the License of this software
@@ -67,7 +68,9 @@ int ifaceMacvtapLinkDump(bool nltarget_kernel, const char *ifname, int ifindex,
 
 int ifaceGetNthParent(int ifindex, const char *ifname, unsigned int nthParent,
                       int *parent_ifindex, char *parent_ifname,
-                      unsigned int *nth);
+                      unsigned int *nth)
+    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
+    ATTRIBUTE_NONNULL(6);
 
 int ifaceReplaceMacAddress(const unsigned char *macaddress,
                            const char *linkdev,