diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-07-07 23:19:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-07-08 11:35:00 +0200 |
commit | 70980a39b84928088b24895ada6fd27c1b6680a9 (patch) | |
tree | 809e04bde2f313ce925c1361c689447d8ce8c129 /src/basic/path-util.h | |
parent | update TODO (diff) | |
download | systemd-70980a39b84928088b24895ada6fd27c1b6680a9.tar.xz systemd-70980a39b84928088b24895ada6fd27c1b6680a9.zip |
path-util: NULL strings are definitely not valid paths
Let's make this functions that check validity of paths a bit more
friendly towards one specific kind of invalid path: a NULL pointer.
This follows similar logic in path_is_valid(), path_is_normalized() and
so on.
Diffstat (limited to '')
-rw-r--r-- | src/basic/path-util.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 553aa4fb58..3413056b31 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -43,12 +43,16 @@ #endif static inline bool is_path(const char *p) { - assert(p); + if (!p) /* A NULL pointer is definitely not a path */ + return false; + return strchr(p, '/'); } static inline bool path_is_absolute(const char *p) { - assert(p); + if (!p) /* A NULL pointer is definitely not an absolute path */ + return false; + return p[0] == '/'; } |