Skip to content

Commit

Permalink
lib: Only call strlen if necessary in strv
Browse files Browse the repository at this point in the history
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
  • Loading branch information
vlendec authored and slowfranklin committed Nov 29, 2017
1 parent 805ae8a commit 8e824ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/util/strv.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ static bool strv_valid_entry(const char *strv, size_t strv_len,
return false;
}

*entry_len = strlen(entry);
if (entry_len != NULL) {
*entry_len = strlen(entry);
}

return true;
}
Expand All @@ -91,7 +93,7 @@ char *strv_next(char *strv, const char *entry)
char *result;

if (entry == NULL) {
if (strv_valid_entry(strv, len, strv, &entry_len)) {
if (strv_valid_entry(strv, len, strv, NULL)) {
return strv;
}
return NULL;
Expand Down

0 comments on commit 8e824ad

Please sign in to comment.