path-util: take char* const* for strv where appropriate

This commit is contained in:
Mike Yuan
2024-05-09 17:02:19 +08:00
parent 7b89efda6f
commit 63a0e57724
2 changed files with 14 additions and 7 deletions
+11 -4
View File
@@ -217,8 +217,10 @@ int path_make_relative_parent(const char *from_child, const char *to, char **ret
return path_make_relative(from, to, ret);
}
char* path_startswith_strv(const char *p, char **set) {
STRV_FOREACH(s, set) {
char* path_startswith_strv(const char *p, char * const *strv) {
assert(p);
STRV_FOREACH(s, strv) {
char *t;
t = path_startswith(p, *s);
@@ -1368,7 +1370,9 @@ bool empty_or_root(const char *path) {
return path_equal(path, "/");
}
bool path_strv_contains(char **l, const char *path) {
bool path_strv_contains(char * const *l, const char *path) {
assert(path);
STRV_FOREACH(i, l)
if (path_equal(*i, path))
return true;
@@ -1376,7 +1380,9 @@ bool path_strv_contains(char **l, const char *path) {
return false;
}
bool prefixed_path_strv_contains(char **l, const char *path) {
bool prefixed_path_strv_contains(char * const *l, const char *path) {
assert(path);
STRV_FOREACH(i, l) {
const char *j = *i;
@@ -1384,6 +1390,7 @@ bool prefixed_path_strv_contains(char **l, const char *path) {
j++;
if (*j == '+')
j++;
if (path_equal(j, path))
return true;
}