mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Replace virStringListHasString by g_strv_contains
The glib variant doesn't accept NULL list, but there's just one caller where it wasn't checked explicitly, thus there's no need for our own wrapper. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d9f7e87673
commit
56cedfcf38
@ -304,7 +304,7 @@ lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab)
|
||||
type = VIR_DOMAIN_FS_TYPE_BLOCK;
|
||||
|
||||
/* Do we have ro in options? */
|
||||
readonly = virStringListHasString((const char **)options, "ro");
|
||||
readonly = g_strv_contains((const char **)options, "ro");
|
||||
|
||||
if (lxcAddFSDef(def, type, src, dst, readonly, usage) < 0)
|
||||
goto cleanup;
|
||||
@ -1108,7 +1108,7 @@ lxcSetCapDrop(virDomainDefPtr def, virConfPtr properties)
|
||||
for (i = 0; i < VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST; i++) {
|
||||
capString = virDomainProcessCapsFeatureTypeToString(i);
|
||||
if (toDrop != NULL &&
|
||||
virStringListHasString((const char **)toDrop, capString))
|
||||
g_strv_contains((const char **)toDrop, capString))
|
||||
def->caps_features[i] = VIR_TRISTATE_SWITCH_OFF;
|
||||
}
|
||||
|
||||
|
@ -2192,10 +2192,10 @@ virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefsPtr defs,
|
||||
for (i = 0; i < defs->ncpus; i++) {
|
||||
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i;
|
||||
|
||||
if (modelAllowed && !virStringListHasString(modelAllowed, cpu->name))
|
||||
if (modelAllowed && !g_strv_contains(modelAllowed, cpu->name))
|
||||
continue;
|
||||
|
||||
if (modelForbidden && virStringListHasString(modelForbidden, cpu->name))
|
||||
if (modelForbidden && g_strv_contains(modelForbidden, cpu->name))
|
||||
continue;
|
||||
|
||||
if (virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
|
||||
@ -3214,7 +3214,7 @@ virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
|
||||
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMModelsToCaps); i++) {
|
||||
const char *needle = virDomainTPMModelTypeToString(
|
||||
virQEMUCapsTPMModelsToCaps[i].type);
|
||||
if (virStringListHasString((const char **)entries, needle))
|
||||
if (g_strv_contains((const char **)entries, needle))
|
||||
virQEMUCapsSet(qemuCaps,
|
||||
virQEMUCapsTPMModelsToCaps[i].caps);
|
||||
}
|
||||
@ -3228,7 +3228,7 @@ virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
|
||||
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMTypesToCaps); i++) {
|
||||
const char *needle = virDomainTPMBackendTypeToString(
|
||||
virQEMUCapsTPMTypesToCaps[i].type);
|
||||
if (virStringListHasString((const char **)entries, needle))
|
||||
if (g_strv_contains((const char **)entries, needle))
|
||||
virQEMUCapsSet(qemuCaps, virQEMUCapsTPMTypesToCaps[i].caps);
|
||||
}
|
||||
}
|
||||
|
@ -3808,7 +3808,7 @@ qemuProcessUpdateDevices(virQEMUDriverPtr driver,
|
||||
return 0;
|
||||
|
||||
for (tmp = old; *tmp; tmp++) {
|
||||
if (!virStringListHasString((const char **) priv->qemuDevices, *tmp) &&
|
||||
if (!g_strv_contains((const char **) priv->qemuDevices, *tmp) &&
|
||||
virDomainDefFindDevice(vm->def, *tmp, &dev, false) == 0 &&
|
||||
qemuDomainRemoveDevice(driver, vm, &dev))
|
||||
return -1;
|
||||
@ -6098,7 +6098,7 @@ qemuProcessDropUnknownCPUFeatures(const char *name,
|
||||
policy != VIR_CPU_FEATURE_FORBID)
|
||||
return true;
|
||||
|
||||
if (virStringListHasString(features, name))
|
||||
if (g_strv_contains(features, name))
|
||||
return true;
|
||||
|
||||
/* Features unknown to QEMU are implicitly disabled, we can just drop them
|
||||
|
@ -1057,13 +1057,13 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
||||
|
||||
ret = 0;
|
||||
for (alias = (const char **) aliases; *alias; alias++) {
|
||||
if (!virStringListHasString(expected, *alias)) {
|
||||
if (!g_strv_contains(expected, *alias)) {
|
||||
fprintf(stderr, "got unexpected device alias '%s'\n", *alias);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
for (alias = expected; *alias; alias++) {
|
||||
if (!virStringListHasString((const char **) aliases, *alias)) {
|
||||
if (!g_strv_contains((const char **) aliases, *alias)) {
|
||||
fprintf(stderr, "missing expected alias '%s'\n", *alias);
|
||||
ret = -1;
|
||||
}
|
||||
@ -2079,7 +2079,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
|
||||
return -1;
|
||||
|
||||
cap = qemuMigrationCapabilityTypeToString(QEMU_MIGRATION_CAP_XBZRLE);
|
||||
if (!virStringListHasString((const char **) caps, cap)) {
|
||||
if (!g_strv_contains((const char **) caps, cap)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Expected capability %s is missing", cap);
|
||||
return -1;
|
||||
|
@ -114,7 +114,8 @@ virshCommaStringListComplete(const char *input,
|
||||
ret = g_new0(char *, optionsLen + 1);
|
||||
|
||||
for (i = 0; i < optionsLen; i++) {
|
||||
if (virStringListHasString((const char **)inputList, options[i]))
|
||||
if (inputList &&
|
||||
g_strv_contains((const char **)inputList, options[i]))
|
||||
continue;
|
||||
|
||||
if (inputCopy)
|
||||
|
Loading…
x
Reference in New Issue
Block a user