[libvirt PATCH] util: fix various ATTRIBUTE_NONNULL calls

Pavel Hrdina posted 1 patch 2 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/9b09a528b0d68c3a0503b826c797bc219326ac64.1637344353.git.phrdina@redhat.com
src/util/viralloc.h             |  2 +-
src/util/virnetdevopenvswitch.h |  2 +-
src/util/virxml.h               | 18 +++++++++---------
3 files changed, 11 insertions(+), 11 deletions(-)

[libvirt PATCH] util: fix various ATTRIBUTE_NONNULL calls

Posted by Pavel Hrdina 2 weeks, 4 days ago
Git bisect took me to commit where incorrect usage of ATTRIBUTE_NONNULL
was introduced and caused coverity scan to fail. This patch fixes the
issue where the index starts from 1 and not 0 and two other different
cases.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/util/viralloc.h             |  2 +-
 src/util/virnetdevopenvswitch.h |  2 +-
 src/util/virxml.h               | 18 +++++++++---------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 3a09af65c5..fe4ecb6620 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -53,7 +53,7 @@ void virAppendElement(void *ptrptr,
                       void *newelem,
                       bool clearOriginal,
                       bool inPlace)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
 int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
                        size_t toremove, bool inPlace)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h
index 4478f2bb37..e275af59df 100644
--- a/src/util/virnetdevopenvswitch.h
+++ b/src/util/virnetdevopenvswitch.h
@@ -82,7 +82,7 @@ int virNetDevOpenvswitchInterfaceClearQos(const char *ifname,
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
 
 int virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname)
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
+ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
 
 int virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname,
                                                     const unsigned char *vmid)
diff --git a/src/util/virxml.h b/src/util/virxml.h
index 06fb7aebd8..5e42fc3591 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -109,14 +109,14 @@ virXMLPropTristateBool(xmlNodePtr node,
                        const char *name,
                        virXMLPropFlags flags,
                        virTristateBool *result)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
 
 int
 virXMLPropTristateSwitch(xmlNodePtr node,
                          const char *name,
                          virXMLPropFlags flags,
                          virTristateSwitch *result)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
 
 int
 virXMLPropInt(xmlNodePtr node,
@@ -125,7 +125,7 @@ virXMLPropInt(xmlNodePtr node,
               virXMLPropFlags flags,
               int *result,
               int defaultResult)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
 
 int
 virXMLPropUInt(xmlNodePtr node,
@@ -133,7 +133,7 @@ virXMLPropUInt(xmlNodePtr node,
                int base,
                virXMLPropFlags flags,
                unsigned int *result)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
 
 int
 virXMLPropULongLong(xmlNodePtr node,
@@ -141,7 +141,7 @@ virXMLPropULongLong(xmlNodePtr node,
                     int base,
                     virXMLPropFlags flags,
                     unsigned long long *result)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
 
 int
 virXMLPropEnum(xmlNodePtr node,
@@ -149,8 +149,8 @@ virXMLPropEnum(xmlNodePtr node,
                int (*strToInt)(const char*),
                virXMLPropFlags flags,
                unsigned int *result)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
-    ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+    ATTRIBUTE_NONNULL(5);
 
 int
 virXMLPropEnumDefault(xmlNodePtr node,
@@ -159,8 +159,8 @@ virXMLPropEnumDefault(xmlNodePtr node,
                       virXMLPropFlags flags,
                       unsigned int *result,
                       unsigned int defaultResult)
-    ATTRIBUTE_NONNULL(0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
-    ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+    ATTRIBUTE_NONNULL(5);
 
 
 /* Internal function; prefer the macros below.  */
-- 
2.31.1

Re: [libvirt PATCH] util: fix various ATTRIBUTE_NONNULL calls

Posted by Ján Tomko 2 weeks, 1 day ago
On a Friday in 2021, Pavel Hrdina wrote:
>Git bisect took me to commit where incorrect usage of ATTRIBUTE_NONNULL
>was introduced and caused coverity scan to fail. This patch fixes the
>issue where the index starts from 1 and not 0 and two other different
>cases.
>
>Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>---
> src/util/viralloc.h             |  2 +-
> src/util/virnetdevopenvswitch.h |  2 +-
> src/util/virxml.h               | 18 +++++++++---------
> 3 files changed, 11 insertions(+), 11 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano