diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-04-12 10:56:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-12 10:56:53 +0200 |
commit | d34f7bd2472220671996609580ee1635b1d683cc (patch) | |
tree | c51a7e54677b4aa5ee06b5fddf9bab2205118082 | |
parent | 7bc5e0b12b7647ac203eeb81092c08724f9bbed3 (diff) | |
parent | 17e4b07088c8772673ecd8e32b6e1d045d8004a6 (diff) | |
download | systemd-d34f7bd2472220671996609580ee1635b1d683cc.tar.gz |
Merge pull request #12287 from keszybz/patches-for-coverity-warnings
Patches for coverity warnings
-rw-r--r-- | src/core/manager.c | 2 | ||||
-rw-r--r-- | src/test/test-env-util.c | 8 | ||||
-rw-r--r-- | src/test/test-exec-util.c | 7 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 4154aec12f..24559a45f3 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -288,7 +288,7 @@ static int manager_check_ask_password(Manager *m) { if (!m->ask_password_event_source) { assert(m->ask_password_inotify_fd < 0); - mkdir_p_label("/run/systemd/ask-password", 0755); + (void) mkdir_p_label("/run/systemd/ask-password", 0755); m->ask_password_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC); if (m->ask_password_inotify_fd < 0) diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c index f57a26021c..17dacda70f 100644 --- a/src/test/test-env-util.c +++ b/src/test/test-env-util.c @@ -122,10 +122,10 @@ static void test_env_strv_get_n(void) { assert_se(!strv_env_get_n(env, "PATH__", 4, 0)); assert_se(!strv_env_get_n(env, "PATH", 4, 0)); - assert_se(streq(strv_env_get_n(env, "PATH__", 4, REPLACE_ENV_USE_ENVIRONMENT), - getenv("PATH"))); - assert_se(streq(strv_env_get_n(env, "PATH", 4, REPLACE_ENV_USE_ENVIRONMENT), - getenv("PATH"))); + assert_se(streq_ptr(strv_env_get_n(env, "PATH__", 4, REPLACE_ENV_USE_ENVIRONMENT), + getenv("PATH"))); + assert_se(streq_ptr(strv_env_get_n(env, "PATH", 4, REPLACE_ENV_USE_ENVIRONMENT), + getenv("PATH"))); } static void test_replace_env(bool braceless) { diff --git a/src/test/test-exec-util.c b/src/test/test-exec-util.c index 25ca7a2bc9..f6f2e6317e 100644 --- a/src/test/test-exec-util.c +++ b/src/test/test-exec-util.c @@ -324,7 +324,7 @@ static void test_environment_gathering(void) { assert_se(chmod(name3, 0755) == 0); /* When booting in containers or without initramfs there might not be - * any PATH in the environ and if there is no PATH /bin/sh built-in + * any PATH in the environment and if there is no PATH /bin/sh built-in * PATH may leak and override systemd's DEFAULT_PATH which is not * good. Force our own PATH in environment, to prevent expansion of sh * built-in $PATH */ @@ -361,7 +361,10 @@ static void test_environment_gathering(void) { assert_se(streq(strv_env_get(env, "PATH"), DEFAULT_PATH ":/no/such/file")); /* reset environ PATH */ - (void) setenv("PATH", old, 1); + if (old) + (void) setenv("PATH", old, 1); + else + (void) unsetenv("PATH"); } static void test_error_catching(void) { |