Merge pull request #12287 from keszybz/patches-for-coverity-warnings

Patches for coverity warnings
This commit is contained in:
Lennart Poettering 2019-04-12 10:56:53 +02:00 committed by GitHub
commit d34f7bd247
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View file

@ -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)

View file

@ -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) {

View file

@ -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) {