mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virHostValidateGetCPUFlags: Use g_strsplit instead of virStringSplitCount
We don't need the count of elements to iterate the list. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ad80bba90a
commit
71eb5e10c0
@ -201,9 +201,8 @@ virBitmapPtr virHostValidateGetCPUFlags(void)
|
|||||||
do {
|
do {
|
||||||
char line[1024];
|
char line[1024];
|
||||||
char *start;
|
char *start;
|
||||||
char **tokens;
|
g_auto(GStrv) tokens = NULL;
|
||||||
size_t ntokens;
|
GStrv next;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (!fgets(line, sizeof(line), fp))
|
if (!fgets(line, sizeof(line), fp))
|
||||||
break;
|
break;
|
||||||
@ -228,20 +227,18 @@ virBitmapPtr virHostValidateGetCPUFlags(void)
|
|||||||
|
|
||||||
/* Split the line using " " as a delimiter. The first token
|
/* Split the line using " " as a delimiter. The first token
|
||||||
* will always be ":", but that's okay */
|
* will always be ":", but that's okay */
|
||||||
if (!(tokens = virStringSplitCount(start, " ", 0, &ntokens)))
|
if (!(tokens = g_strsplit(start, " ", 0)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Go through all flags and check whether one of those we
|
/* Go through all flags and check whether one of those we
|
||||||
* might want to check for later on is present; if that's
|
* might want to check for later on is present; if that's
|
||||||
* the case, set the relevant bit in the bitmap */
|
* the case, set the relevant bit in the bitmap */
|
||||||
for (i = 0; i < ntokens; i++) {
|
for (next = tokens; *next; next++) {
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if ((value = virHostValidateCPUFlagTypeFromString(tokens[i])) >= 0)
|
if ((value = virHostValidateCPUFlagTypeFromString(*next)) >= 0)
|
||||||
ignore_value(virBitmapSetBit(flags, value));
|
ignore_value(virBitmapSetBit(flags, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
virStringListFreeCount(tokens, ntokens);
|
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
VIR_FORCE_FCLOSE(fp);
|
VIR_FORCE_FCLOSE(fp);
|
||||||
|
Loading…
Reference in New Issue
Block a user