]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/test-path-util.c
path-util: tighten path_extract_filename()
authorLennart Poettering <lennart@poettering.net>
Mon, 25 Jan 2021 18:50:47 +0000 (19:50 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 2 Feb 2021 23:16:38 +0000 (23:16 +0000)
commit3cdcbdd32f8deaf4fbfeaaa908e77917229c661a
treefca60e434f4c08c8a95b05d20152bc917a1ee1d0
parent23cfef7bb106784c1b25e154ff88b67b039927be
path-util: tighten path_extract_filename()

Let's tighten the logic behind path_extract_filename() a bit: first of
all, refuse all cases of invalid paths with -EINVAL. More importantly
though return a recognizable error when a valid path is specified that
does not contain any filename. Specifically, "/" will now result in
-EADDRNOTAVAIL.

This changes API, but none of the existing callers care about the return
value, hence the change should be fine.
src/basic/path-util.c
src/test/test-path-util.c