[PATCH 14/39] virLogParseFilters: Refactor string list handling
Ján Tomko
jtomko at redhat.com
Wed Apr 7 16:05:16 UTC 2021
On a Thursday in 2021, Peter Krempa wrote:
>Rewrite the code to remove the need to calculate the string list count.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/util/virlog.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/src/util/virlog.c b/src/util/virlog.c
>index 56059f62f1..57eb0de538 100644
>--- a/src/util/virlog.c
>+++ b/src/util/virlog.c
>@@ -1668,22 +1668,22 @@ int
> virLogParseFilters(const char *src, virLogFilterPtr **filters)
> {
> size_t nfilters = 0;
>- size_t i, count;
> g_auto(GStrv) strings = NULL;
>+ GStrv next;
> virLogFilterPtr filter = NULL;
> virLogFilterPtr *list = NULL;
>
> VIR_DEBUG("filters=%s", src);
>
>- if (!(strings = virStringSplitCount(src, " ", 0, &count)))
>+ if (!(strings = g_strsplit(src, " ", 0)))
> return -1;
>
>- for (i = 0; i < count; i++) {
>+ for (next = strings; *next; next++) {
> /* virStringSplit may return empty strings */
This comment is now outdated: the sequel
>- if (STREQ(strings[i], ""))
>+ if (STREQ(*next, ""))
> continue;
>
>- if (!(filter = virLogParseFilter(strings[i])))
>+ if (!(filter = virLogParseFilter(*next)))
> return -1;
>
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210407/5f12a042/attachment-0001.sig>
More information about the libvir-list
mailing list