Replace virStringListLength by g_strv_length

The glib implementation doesn't tolerate NULL but in most cases we check
before anyways. The rest of the callers adds a NULL check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa
2021-02-05 18:03:26 +01:00
parent 1114cf5e7e
commit dcd547aec1
13 changed files with 25 additions and 19 deletions

View File

@@ -394,7 +394,7 @@ static int testConfParseStringList(const void *opaque G_GNUC_UNUSED)
if (virConfGetValueStringList(conf, "string_list", false, &str) < 0)
goto cleanup;
if (virStringListLength((const char *const*)str) != 2) {
if (!str || g_strv_length(str) != 2) {
fprintf(stderr, "expected a 2 element list\n");
goto cleanup;
}
@@ -418,7 +418,7 @@ static int testConfParseStringList(const void *opaque G_GNUC_UNUSED)
if (virConfGetValueStringList(conf, "string", true, &str) < 0)
goto cleanup;
if (virStringListLength((const char *const*)str) != 1) {
if (!str || g_strv_length(str) != 1) {
fprintf(stderr, "expected a 1 element list\n");
goto cleanup;
}

View File

@@ -243,10 +243,10 @@ testStringSearch(const void *opaque)
goto cleanup;
}
if (virStringListLength((const char * const *)matches) != nmatches) {
fprintf(stderr, "expected %zu matches on %s but got %zd matches\n",
if (g_strv_length(matches) != nmatches) {
fprintf(stderr, "expected %zu matches on %s but got %u matches\n",
data->expectNMatches, data->str,
virStringListLength((const char * const *)matches));
g_strv_length(matches));
goto cleanup;
}