tree-wide: unsetenv cannot fail

... when called with a valid environment variable name. This means that
any time we call it with a fixed string, it is guaranteed to return 0.
(Also when the variable is not present in the environment block.)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-11-10 15:52:32 +01:00
parent 063f9f0da9
commit 44ee03d111
8 changed files with 22 additions and 32 deletions
+5 -5
View File
@@ -898,11 +898,11 @@ int main(int argc, char *argv[]) {
}
#endif
(void) unsetenv("USER");
(void) unsetenv("LOGNAME");
(void) unsetenv("SHELL");
(void) unsetenv("HOME");
(void) unsetenv("TMPDIR");
assert_se(unsetenv("USER") == 0);
assert_se(unsetenv("LOGNAME") == 0);
assert_se(unsetenv("SHELL") == 0);
assert_se(unsetenv("HOME") == 0);
assert_se(unsetenv("TMPDIR") == 0);
can_unshare = have_namespaces();
+2 -2
View File
@@ -184,7 +184,7 @@ static void test_find_executable_full(void) {
if (p)
assert_se(oldpath = strdup(p));
assert_se(unsetenv("PATH") >= 0);
assert_se(unsetenv("PATH") == 0);
assert_se(find_executable_full("sh", true, &p) == 0);
puts(p);
@@ -347,7 +347,7 @@ static void test_fsck_exists(void) {
log_info("/* %s */", __func__);
/* Ensure we use a sane default for PATH. */
unsetenv("PATH");
assert_se(unsetenv("PATH") == 0);
/* fsck.minix is provided by util-linux and will probably exist. */
assert_se(fsck_exists("minix") == 1);
+1 -1
View File
@@ -480,7 +480,7 @@ static void test_in_utc_timezone(void) {
assert_se(streq(tzname[0], "CET"));
assert_se(streq(tzname[1], "CEST"));
assert_se(unsetenv("TZ") >= 0);
assert_se(unsetenv("TZ") == 0);
}
static void test_map_clock_usec(void) {