Skip to content

Commit

Permalink
lib/list.c: is_on_list(): Move break condition to loop controlling ex…
Browse files Browse the repository at this point in the history
…pression

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 <[email protected]>
  • Loading branch information
alejandro-colomar authored and hallyn committed Mar 14, 2024
1 parent fb01e07 commit 46fd68c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46fd68c

Please sign in to comment.