mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
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.
This commit is contained in:
parent
b467422bd2
commit
70980a39b8
|
@ -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] == '/';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue