From de5ba4c6053abfb4dab3def5862c50d5d86153ea Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 16 Oct 2023 15:00:01 +0200 Subject: [PATCH] glib-aux: use nm_streq() in _nm_strv_find_first() instead of strcmp() nm_streq() is better for readability. Prefer it over strcmp(). Note that nm_streq() will be inlined, so it should make no difference performance wise. While at it, drop wrong comment. --- src/libnm-glib-aux/nm-shared-utils.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index 34a3af2053..d391261f05 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -1964,8 +1964,6 @@ nm_utils_strsplit_quoted(const char *str) * Searches @list for @needle and returns the index of the first match (based * on strcmp()). * - * For convenience, @list has type 'char**' instead of 'const char **'. - * * Returns: index of first occurrence or -1 if @needle is not found in @list. */ gssize @@ -1984,7 +1982,7 @@ _nm_strv_find_first(const char *const *list, gssize len, const char *needle) } } else { for (i = 0; i < len; i++) { - if (list[i] && !strcmp(needle, list[i])) + if (list[i] && nm_streq(needle, list[i])) return i; } } @@ -1993,7 +1991,7 @@ _nm_strv_find_first(const char *const *list, gssize len, const char *needle) if (list) { for (i = 0; list[i]; i++) { - if (strcmp(needle, list[i]) == 0) + if (nm_streq(needle, list[i])) return i; } }