From 8e824ad69700412cedeb758029fdad4d1b5c6bbe Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 2 Aug 2017 17:32:50 +0200 Subject: [PATCH] lib: Only call strlen if necessary in strv Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- lib/util/strv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/util/strv.c b/lib/util/strv.c index 864a3e5cf8b..328f561722b 100644 --- a/lib/util/strv.c +++ b/lib/util/strv.c @@ -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; } @@ -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; -- 2.34.1