]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
util: Promote path_is_absolute() to header
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 14 Nov 2024 15:48:30 +0000 (09:48 -0600)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 21 Nov 2024 04:25:30 +0000 (22:25 -0600)
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 <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/243
shared/util.c
shared/util.h

index 7a1f3ee8b3e7d7374a06b6a7b8f7a7b071e06180..5d05c0144a3ec98d3455d39eb72df913a2ded3eb 100644 (file)
@@ -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;
index 65d90dba743fb03aded837d806d80a2c95aff6a2..58431baa11c4e7cbd4f7083720fbc6d400910abf 100644 (file)
@@ -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);