From: Mike Yuan Date: Mon, 29 Jan 2024 17:50:01 +0000 (+0800) Subject: env-util: don't use strlen_ptr if known non-NULL X-Git-Tag: v256-rc1~1014^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=17ca1517332d6b2a354ff7edfa92053f53e93938;p=thirdparty%2Fsystemd.git env-util: don't use strlen_ptr if known non-NULL --- diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 38387cb2ff3..ad3130f445b 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -529,17 +529,16 @@ int _strv_env_assign_many(char ***l, ...) { return 0; } -char *strv_env_get_n(char **l, const char *name, size_t k, ReplaceEnvFlags flags) { +char* strv_env_get_n(char **l, const char *name, size_t k, ReplaceEnvFlags flags) { assert(name); if (k == SIZE_MAX) - k = strlen_ptr(name); + k = strlen(name); if (k <= 0) return NULL; STRV_FOREACH_BACKWARDS(i, l) - if (strneq(*i, name, k) && - (*i)[k] == '=') + if (strneq(*i, name, k) && (*i)[k] == '=') return *i + k + 1; if (flags & REPLACE_ENV_USE_ENVIRONMENT) { diff --git a/src/basic/env-util.h b/src/basic/env-util.h index 332efcf1b74..f722a124d94 100644 --- a/src/basic/env-util.h +++ b/src/basic/env-util.h @@ -53,8 +53,8 @@ int strv_env_assignf(char ***l, const char *key, const char *valuef, ...) _print int _strv_env_assign_many(char ***l, ...) _sentinel_; #define strv_env_assign_many(l, ...) _strv_env_assign_many(l, __VA_ARGS__, NULL) -char *strv_env_get_n(char **l, const char *name, size_t k, ReplaceEnvFlags flags) _pure_; -static inline char *strv_env_get(char **x, const char *n) { +char* strv_env_get_n(char **l, const char *name, size_t k, ReplaceEnvFlags flags) _pure_; +static inline char* strv_env_get(char **x, const char *n) { return strv_env_get_n(x, n, SIZE_MAX, 0); }