mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
util: virpcivpd: Remove return value from virPCIVPDResourceCustomUpsertValue
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>
This commit is contained in:
parent
ab3f4d1b0b
commit
d36da8ea4a
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user