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.
This commit is contained in:
committed by
Luca Boccassi
parent
23cfef7bb1
commit
3cdcbdd32f
@@ -578,9 +578,9 @@ static void test_path_extract_filename(void) {
|
||||
test_path_extract_filename_one(NULL, NULL, -EINVAL);
|
||||
test_path_extract_filename_one("a/b/c", "c", 0);
|
||||
test_path_extract_filename_one("a/b/c/", "c", 0);
|
||||
test_path_extract_filename_one("/", NULL, -EINVAL);
|
||||
test_path_extract_filename_one("//", NULL, -EINVAL);
|
||||
test_path_extract_filename_one("///", NULL, -EINVAL);
|
||||
test_path_extract_filename_one("/", NULL, -EADDRNOTAVAIL);
|
||||
test_path_extract_filename_one("//", NULL, -EADDRNOTAVAIL);
|
||||
test_path_extract_filename_one("///", NULL, -EADDRNOTAVAIL);
|
||||
test_path_extract_filename_one(".", NULL, -EINVAL);
|
||||
test_path_extract_filename_one("./.", NULL, -EINVAL);
|
||||
test_path_extract_filename_one("././", NULL, -EINVAL);
|
||||
|
||||
Reference in New Issue
Block a user