basic/strv: return NULL from strv_skip

strv_skip was written to carefully return the original array, but this turns
out to be an unnecessary complication. After the previous patch, no caller
cares about the distinction between NULL and { NULL }, but various callers need
to wrap the process the returned value with strv_isempty(), sometimes more than
once. Let's always return NULL for an empty result to allow callers to be
simplified.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-03-27 12:04:23 +01:00
parent 872710c437
commit 55a8d118d6
3 changed files with 27 additions and 21 deletions
+4 -2
View File
@@ -976,14 +976,16 @@ bool strv_fnmatch_full(
}
char** strv_skip(char **l, size_t n) {
while (n > 0) {
if (strv_isempty(l))
return l;
return NULL;
l++, n--;
}
/* To simplify callers, always return NULL instead of a zero-item array. */
if (strv_isempty(l))
return NULL;
return l;
}