From 8fb954b81d6f6ebc5f0b4fda3efa6f02f4c06e8a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 2 Aug 2019 09:37:46 +0200 Subject: [PATCH] shared: refactor nm_utils_g_slist_strlist_cmp() to avoid dead-code warning from Coverity Coverity sees that "return 0" cannot be reached. Refactor the code, to avoid the warning. --- shared/nm-glib-aux/nm-shared-utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 33749d3a1c..9bfd5ae2b8 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -2834,10 +2834,15 @@ nm_utils_g_slist_find_str (const GSList *list, int nm_utils_g_slist_strlist_cmp (const GSList *a, const GSList *b) { - for (; a && b; a = a->next, b = b->next) + while (TRUE) { + if (!a) + return !b ? 0 : -1; + if (!b) + return 1; NM_CMP_DIRECT_STRCMP0 (a->data, b->data); - NM_CMP_SELF (a, b); - return 0; + a = a->next; + b = b->next; + } } /*****************************************************************************/