From: Lucas De Marchi Date: Thu, 14 Nov 2024 15:48:30 +0000 (-0600) Subject: util: Promote path_is_absolute() to header X-Git-Tag: v34~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63302cf6551318adf5512f004d32a87c57fe86a6;p=thirdparty%2Fkmod.git util: Promote path_is_absolute() to header This is a trivial function that can be used elsewhere. There's no point in keeping the assert if we are going to crash in the very next instruction. Rather add the relevant attribute and drop the assert. Signed-off-by: Lucas De Marchi Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/243 --- diff --git a/shared/util.c b/shared/util.c index 7a1f3ee8..5d05c014 100644 --- a/shared/util.c +++ b/shared/util.c @@ -369,13 +369,6 @@ char *freadline_wrapped(FILE *fp, unsigned int *linenum) /* path handling functions */ /* ************************************************************************ */ -static bool path_is_absolute(const char *p) -{ - assert(p != NULL); - - return p[0] == '/'; -} - char *path_make_absolute_cwd(const char *p) { _cleanup_free_ char *cwd = NULL; diff --git a/shared/util.h b/shared/util.h index 65d90dba..58431baa 100644 --- a/shared/util.h +++ b/shared/util.h @@ -45,6 +45,11 @@ _nonnull_(1) char *freadline_wrapped(FILE *fp, unsigned int *linenum); /* path handling functions */ /* ************************************************************************ */ _must_check_ _nonnull_all_ char *path_make_absolute_cwd(const char *p); +static inline _must_check_ _nonnull_all_ bool path_is_absolute(const char *p) +{ + return p[0] == '/'; +} + int mkdir_p(const char *path, int len, mode_t mode); int mkdir_parents(const char *path, mode_t mode); unsigned long long stat_mstamp(const struct stat *st);