tree-wide: Workaround -Wnonnull GCC bug

See issue #6119
This commit is contained in:
Benjamin Robin
2020-05-07 09:43:28 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent ba876a4c8d
commit 08f468567d
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -1013,10 +1013,14 @@ static int install_info_add(
int r;
assert(c);
assert(name || path);
if (!name)
if (!name) {
/* 'name' and 'path' must not both be null. Check here 'path' using assert_se() to
* workaround a bug in gcc that generates a -Wnonnull warning when calling basename(),
* but this cannot be possible in any code path (See #6119). */
assert_se(path);
name = basename(path);
}
if (!unit_name_is_valid(name, UNIT_NAME_ANY))
return -EINVAL;