diff options
author | Alejandro Colomar <alx@kernel.org> | 2024-01-17 02:50:42 +0100 |
---|---|---|
committer | Serge Hallyn <serge@hallyn.com> | 2024-03-14 17:11:36 -0500 |
commit | 46fd68c37e63e7c00b922c86c8e83aea4142510a (patch) | |
tree | e3481a79d4ff57f929c0eff9445c0244df06c771 | |
parent | fb01e07e83763733a2ad825ef6fc6974b25401f9 (diff) |
lib/list.c: is_on_list(): Move break condition to loop controlling expression
This change executes `i++` one more time before breaking, so we need to
update the `i+1` after the loop to just `i`.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | lib/list.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -232,15 +232,13 @@ bool is_on_list (char *const *list, const char *member) * array of pointers. */ - for (cp = members, i = 0;; i++) { + for (cp = members, i = 0; cp != NULL; i++) { array[i] = cp; cp = strchr(cp, ','); if (NULL != cp) *cp++ = '\0'; - else - break; } - array[i+1] = NULL; + array[i] = NULL; /* * Return the new array of pointers |