Merge pull request #13239 from poettering/coverity-fixes

four coverity fixes
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-07-31 16:08:52 +02:00 committed by GitHub
commit 1be8044b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 12 deletions

View File

@ -1153,8 +1153,11 @@ void job_add_to_run_queue(Job *j) {
log_warning_errno(r, "Failed to enable job run queue event source, ignoring: %m");
}
prioq_put(j->manager->run_queue, j, &j->run_queue_idx);
j->in_run_queue = true;
r = prioq_put(j->manager->run_queue, j, &j->run_queue_idx);
if (r < 0)
log_warning_errno(r, "Failed put job in run queue, ignoring: %m");
else
j->in_run_queue = true;
}
void job_add_to_dbus_queue(Job *j) {

View File

@ -46,30 +46,30 @@ STATIC_DESTRUCTOR_REGISTER(arg_disks, hashmap_freep);
STATIC_DESTRUCTOR_REGISTER(arg_default_options, freep);
STATIC_DESTRUCTOR_REGISTER(arg_default_keyfile, freep);
static int split_keyspec(const char *keyspec, char **keyfile, char **keydev) {
static int split_keyspec(const char *keyspec, char **ret_keyfile, char **ret_keydev) {
_cleanup_free_ char *kfile = NULL, *kdev = NULL;
char *c;
const char *c;
assert(keyspec);
assert(keyfile);
assert(keydev);
assert(ret_keyfile);
assert(ret_keydev);
c = strrchr(keyspec, ':');
if (c) {
kfile = strndup(keyspec, c-keyspec);
kdev = strdup(c + 1);
if (!*kfile || !*kdev)
if (!kfile || !kdev)
return log_oom();
} else {
/* No keydev specified */
kfile = strdup(keyspec);
kdev = NULL;
if (!*kfile)
if (!kfile)
return log_oom();
}
*keyfile = TAKE_PTR(kfile);
*keydev = TAKE_PTR(kdev);
*ret_keyfile = TAKE_PTR(kfile);
*ret_keydev = TAKE_PTR(kdev);
return 0;
}

View File

@ -462,7 +462,7 @@ int unit_file_find_fragment(
r = unit_ids_map_get(unit_ids_map, template, &fragment);
if (r < 0 && !IN_SET(r, -ENOENT, -ENXIO))
return log_debug_errno(r, "Cannot load template %s: %m", *t);
return log_debug_errno(r, "Cannot load template %s: %m", template);
if (fragment) {
/* Add any aliases of the original name to the set of names */

View File

@ -1,8 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <getopt.h>
#include "log.h"
#include "fd-util.h"
#include "fs-util.h"
#include "log.h"
#include "main-func.h"
static char *arg_root = NULL;
@ -97,6 +98,9 @@ static int run(int argc, char **argv) {
log_error_errno(r, "failed: %m");
else
log_info("→ %s", p);
if (FLAGS_SET(arg_flags, CHASE_OPEN))
safe_close(r);
}
return 0;