mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-04-25 12:00:39 +02:00
util: return early when listing files from a NULL directory list
For consistency with "no matching file found" return a single-null-entry array. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1212>
This commit is contained in:
parent
d5761547da
commit
46950de903
2 changed files with 11 additions and 0 deletions
|
|
@ -87,6 +87,12 @@ list_files(const char **directories,
|
|||
{
|
||||
struct list files = LIST_INIT(files);
|
||||
|
||||
if (!directories) {
|
||||
if (nfiles_out)
|
||||
*nfiles_out = 0;
|
||||
return zalloc(1 * sizeof(char*));
|
||||
}
|
||||
|
||||
const char **d = directories;
|
||||
while (*d) {
|
||||
struct list new_files = LIST_INIT(new_files);
|
||||
|
|
|
|||
|
|
@ -220,6 +220,11 @@ START_TEST(find_files_test)
|
|||
litest_assert_int_eq(nfiles, (size_t)0);
|
||||
litest_assert_ptr_notnull(empty_path);
|
||||
litest_assert_ptr_null(empty_path[0]);
|
||||
|
||||
_autostrvfree_ char** also_empty_path = list_files(NULL, "suf", &nfiles);
|
||||
litest_assert_int_eq(nfiles, (size_t)0);
|
||||
litest_assert_ptr_notnull(also_empty_path);
|
||||
litest_assert_ptr_null(also_empty_path[0]);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue