]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: virpcivpd: Remove return value from virPCIVPDResourceCustomUpsertValue
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Jan 2024 15:11:24 +0000 (16:11 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 31 Jan 2024 16:24:07 +0000 (17:24 +0100)
None of the callers pass NULL, so the NULL check is pointless. Remove it
an remove the return value.

The function is exported only for use in 'virpcivpdtest' thus marking
the arguments as NONNULL is unnecessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virpcivpd.c
src/util/virpcivpdpriv.h
tests/virpcivpdtest.c

index 67065dec460d7107bfa32960d487c534379f7150..f198faaf42d12960b40c82929b30aae8c7c19f5c 100644 (file)
@@ -270,7 +270,7 @@ virPCIVPDResourceCustomCompareIndex(virPCIVPDResourceCustom *a, virPCIVPDResourc
  *
  * Returns: true if a value has been updated successfully, false otherwise.
  */
-bool
+void
 virPCIVPDResourceCustomUpsertValue(GPtrArray *arr, char index, const char *const value)
 {
     g_autoptr(virPCIVPDResourceCustom) custom = NULL;
@@ -278,9 +278,6 @@ virPCIVPDResourceCustomUpsertValue(GPtrArray *arr, char index, const char *const
     guint pos = 0;
     bool found = false;
 
-    if (arr == NULL || value == NULL)
-        return false;
-
     custom = g_new0(virPCIVPDResourceCustom, 1);
     custom->idx = index;
     custom->value = g_strdup(value);
@@ -294,7 +291,6 @@ virPCIVPDResourceCustomUpsertValue(GPtrArray *arr, char index, const char *const
     } else {
         g_ptr_array_add(arr, g_steal_pointer(&custom));
     }
-    return true;
 }
 
 /**
@@ -348,9 +344,7 @@ virPCIVPDResourceUpdateKeyword(virPCIVPDResource *res, const bool readOnly,
             res->ro->serial_number = g_strdup(value);
             return true;
         } else if (virPCIVPDResourceIsVendorKeyword(keyword)) {
-            if (!virPCIVPDResourceCustomUpsertValue(res->ro->vendor_specific, keyword[1], value)) {
-                return false;
-            }
+            virPCIVPDResourceCustomUpsertValue(res->ro->vendor_specific, keyword[1], value);
             return true;
         } else if (STREQ("FG", keyword) || STREQ("LC", keyword) || STREQ("PG", keyword)) {
             /* Legacy PICMIG keywords are skipped on purpose. */
@@ -371,14 +365,10 @@ virPCIVPDResourceUpdateKeyword(virPCIVPDResource *res, const bool readOnly,
             res->rw->asset_tag = g_strdup(value);
             return true;
         } else if (virPCIVPDResourceIsVendorKeyword(keyword)) {
-            if (!virPCIVPDResourceCustomUpsertValue(res->rw->vendor_specific, keyword[1], value)) {
-                return false;
-            }
+            virPCIVPDResourceCustomUpsertValue(res->rw->vendor_specific, keyword[1], value);
             return true;
         } else if (virPCIVPDResourceIsSystemKeyword(keyword)) {
-            if (!virPCIVPDResourceCustomUpsertValue(res->rw->system_specific, keyword[1], value)) {
-                return false;
-            }
+            virPCIVPDResourceCustomUpsertValue(res->rw->system_specific, keyword[1], value);
             return true;
         }
     }
index 617991930b13279c139a09776e482d16ebc6f2c3..f26b64139d22f0d4d2c3dbd8c7037353c05d404f 100644 (file)
@@ -66,5 +66,5 @@ bool virPCIVPDResourceIsValidTextValue(const char *value);
 gboolean
 virPCIVPDResourceCustomCompareIndex(virPCIVPDResourceCustom *a, virPCIVPDResourceCustom *b);
 
-bool
+void
 virPCIVPDResourceCustomUpsertValue(GPtrArray *arr, char index, const char *const value);
index fddb42f52c2e7bf64e5d4f6d5afb7e222831c5a6..8a2f337e854ae00a25bdf8cf40d2661094e14f4e 100644 (file)
@@ -244,8 +244,7 @@ testPCIVPDResourceCustomUpsertValue(const void *data G_GNUC_UNUSED)
 {
     g_autoptr(GPtrArray) arr = g_ptr_array_new_full(0, (GDestroyNotify)virPCIVPDResourceCustomFree);
     virPCIVPDResourceCustom *custom = NULL;
-    if (!virPCIVPDResourceCustomUpsertValue(arr, 'A', "testval"))
-        return -1;
+    virPCIVPDResourceCustomUpsertValue(arr, 'A', "testval");
 
     if (arr->len != 1)
         return -1;
@@ -255,8 +254,7 @@ testPCIVPDResourceCustomUpsertValue(const void *data G_GNUC_UNUSED)
         return -1;
 
     /* Idempotency */
-    if (!virPCIVPDResourceCustomUpsertValue(arr, 'A', "testval"))
-        return -1;
+    virPCIVPDResourceCustomUpsertValue(arr, 'A', "testval");
 
     if (arr->len != 1)
         return -1;
@@ -266,8 +264,7 @@ testPCIVPDResourceCustomUpsertValue(const void *data G_GNUC_UNUSED)
         return -1;
 
     /* Existing value updates. */
-    if (!virPCIVPDResourceCustomUpsertValue(arr, 'A', "testvalnew"))
-        return -1;
+    virPCIVPDResourceCustomUpsertValue(arr, 'A', "testvalnew");
 
     if (arr->len != 1)
         return -1;
@@ -277,8 +274,7 @@ testPCIVPDResourceCustomUpsertValue(const void *data G_GNUC_UNUSED)
         return -1;
 
     /* Inserting multiple values */
-    if (!virPCIVPDResourceCustomUpsertValue(arr, '1', "42"))
-        return -1;
+    virPCIVPDResourceCustomUpsertValue(arr, '1', "42");
 
     if (arr->len != 2)
         return -1;