summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-25 13:12:44 +0200
committerGitHub <noreply@github.com>2018-06-25 13:12:44 +0200
commit2919425bab78289f0cff7d94b7ebe0a91e037404 (patch)
treef5336c4c96c06ae09dafb039f3b14beff035094c
parentcore/manager: Make sure jobs statistics are not double after daemon-reload (diff)
parentinstall: fix error handling in is_symlink_with_known_name() (diff)
downloadsystemd-2919425bab78289f0cff7d94b7ebe0a91e037404.tar.xz
systemd-2919425bab78289f0cff7d94b7ebe0a91e037404.zip
Merge pull request #9398 from yuwata/lgtm-fixes
fixes error handlings and several cleanups suggested by LGTM
-rw-r--r--src/basic/crypt-util.h1
-rw-r--r--src/basic/exec-util.h1
-rw-r--r--src/boot/bootctl.c14
-rw-r--r--src/core/cgroup.c2
-rw-r--r--src/fuzz/fuzz.h1
-rw-r--r--src/import/pull-common.c3
-rw-r--r--src/journal/journald-server.c2
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c5
-rw-r--r--src/locale/keymap-util.h1
-rw-r--r--src/portable/portable.c2
-rw-r--r--src/portable/portabled-image-bus.h1
-rw-r--r--src/portable/portabled-image.h1
-rw-r--r--src/resolve/resolvconf-compat.h1
-rw-r--r--src/resolve/resolvectl.h1
-rw-r--r--src/resolve/resolved-dns-answer.c3
-rw-r--r--src/resolve/resolved-dns-answer.h2
-rw-r--r--src/resolve/resolved-dns-cache.c9
-rw-r--r--src/resolve/resolved-dns-query.c16
-rw-r--r--src/resolve/resolved-dns-transaction.c5
-rw-r--r--src/shared/bus-util.c2
-rw-r--r--src/shared/install.c2
-rw-r--r--src/shared/journal-util.h1
-rw-r--r--src/shared/machine-pool.c3
23 files changed, 31 insertions, 48 deletions
diff --git a/src/basic/crypt-util.h b/src/basic/crypt-util.h
index 5b03cb072d..8c86714aec 100644
--- a/src/basic/crypt-util.h
+++ b/src/basic/crypt-util.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#if HAVE_LIBCRYPTSETUP
#include <libcryptsetup.h>
diff --git a/src/basic/exec-util.h b/src/basic/exec-util.h
index 8b1f18139c..823ca6578c 100644
--- a/src/basic/exec-util.h
+++ b/src/basic/exec-util.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include <stdbool.h>
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 2832a39dd7..b74129a5f0 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -950,18 +950,8 @@ static int verb_status(int argc, char *argv[], void *userdata) {
printf("System:\n");
printf(" Firmware: %s (%s)\n", strna(fw_type), strna(fw_info));
-
- k = is_efi_secure_boot();
- if (k < 0)
- r = log_warning_errno(k, "Failed to query secure boot status: %m");
- else
- printf(" Secure Boot: %sd\n", enable_disable(k));
-
- k = is_efi_secure_boot_setup_mode();
- if (k < 0)
- r = log_warning_errno(k, "Failed to query secure boot mode: %m");
- else
- printf(" Setup Mode: %s\n", k ? "setup" : "user");
+ printf(" Secure Boot: %sd\n", enable_disable(is_efi_secure_boot()));
+ printf(" Setup Mode: %s\n", is_efi_secure_boot_setup_mode() ? "setup" : "user");
printf("\n");
printf("Current Loader:\n");
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index bb02436203..d4b9bdb884 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -2260,7 +2260,7 @@ int manager_setup_cgroup(Manager *m) {
if (m->pin_cgroupfs_fd < 0)
return log_error_errno(errno, "Failed to open pin file: %m");
- } else if (r < 0 && !m->test_run_flags)
+ } else if (!m->test_run_flags)
return log_error_errno(r, "Failed to create %s control group: %m", scope_path);
/* 7. Always enable hierarchical support if it exists... */
diff --git a/src/fuzz/fuzz.h b/src/fuzz/fuzz.h
index e2bfab3168..1e56526259 100644
--- a/src/fuzz/fuzz.h
+++ b/src/fuzz/fuzz.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include <stddef.h>
#include <stdint.h>
diff --git a/src/import/pull-common.c b/src/import/pull-common.c
index 4117ed2e6a..459024fb22 100644
--- a/src/import/pull-common.c
+++ b/src/import/pull-common.c
@@ -520,8 +520,7 @@ int pull_verify(PullJob *main_job,
}
finish:
- if (sig_file >= 0)
- (void) unlink(sig_file_path);
+ (void) unlink(sig_file_path);
if (gpg_home_created)
(void) rm_rf(gpg_home, REMOVE_ROOT|REMOVE_PHYSICAL);
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 4f1550ec5b..7a11feeb6a 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -309,7 +309,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
server_add_acls(s->system_journal, 0);
(void) cache_space_refresh(s, &s->system_storage);
patch_min_use(&s->system_storage);
- } else if (r < 0) {
+ } else {
if (!IN_SET(r, -ENOENT, -EROFS))
log_warning_errno(r, "Failed to open system journal: %m");
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index b3bc259280..ff54d7e20c 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -1144,9 +1144,8 @@ static int client_receive_message(
return 0;
}
- if (r >= 0)
- log_dhcp6_client(client, "Recv %s",
- dhcp6_message_type_to_string(message->type));
+ log_dhcp6_client(client, "Recv %s",
+ dhcp6_message_type_to_string(message->type));
return 0;
}
diff --git a/src/locale/keymap-util.h b/src/locale/keymap-util.h
index c55c9f92a6..902da689c8 100644
--- a/src/locale/keymap-util.h
+++ b/src/locale/keymap-util.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include "sd-bus.h"
diff --git a/src/portable/portable.c b/src/portable/portable.c
index eb5daf3b0e..3491723aa1 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -782,7 +782,7 @@ static int install_profile_dropin(
r = find_profile(profile, m->name, &from);
if (r < 0) {
- if (r != ENOENT)
+ if (r != -ENOENT)
return log_debug_errno(errno, "Profile '%s' is not accessible: %m", profile);
log_debug_errno(errno, "Skipping link to profile '%s', as it does not exist: %m", profile);
diff --git a/src/portable/portabled-image-bus.h b/src/portable/portabled-image-bus.h
index 81c17f68af..825dea2682 100644
--- a/src/portable/portabled-image-bus.h
+++ b/src/portable/portabled-image-bus.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include "sd-bus.h"
diff --git a/src/portable/portabled-image.h b/src/portable/portabled-image.h
index f29bd89e83..26ce2f6b59 100644
--- a/src/portable/portabled-image.h
+++ b/src/portable/portabled-image.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include "hashmap.h"
#include "machine-image.h"
diff --git a/src/resolve/resolvconf-compat.h b/src/resolve/resolvconf-compat.h
index 507ac3d222..872add1d56 100644
--- a/src/resolve/resolvconf-compat.h
+++ b/src/resolve/resolvconf-compat.h
@@ -1,3 +1,4 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
int resolvconf_parse_argv(int argc, char *argv[]);
diff --git a/src/resolve/resolvectl.h b/src/resolve/resolvectl.h
index 6ecaa4ff31..9008daace5 100644
--- a/src/resolve/resolvectl.h
+++ b/src/resolve/resolvectl.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include <in-addr-util.h>
#include <stdbool.h>
diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c
index 26caa63f94..66dc5d0299 100644
--- a/src/resolve/resolved-dns-answer.c
+++ b/src/resolve/resolved-dns-answer.c
@@ -799,7 +799,7 @@ void dns_answer_dump(DnsAnswer *answer, FILE *f) {
}
}
-bool dns_answer_has_dname_for_cname(DnsAnswer *a, DnsResourceRecord *cname) {
+int dns_answer_has_dname_for_cname(DnsAnswer *a, DnsResourceRecord *cname) {
DnsResourceRecord *rr;
int r;
@@ -830,7 +830,6 @@ bool dns_answer_has_dname_for_cname(DnsAnswer *a, DnsResourceRecord *cname) {
return r;
if (r > 0)
return 1;
-
}
return 0;
diff --git a/src/resolve/resolved-dns-answer.h b/src/resolve/resolved-dns-answer.h
index aff594a00e..9ce7d62773 100644
--- a/src/resolve/resolved-dns-answer.h
+++ b/src/resolve/resolved-dns-answer.h
@@ -65,7 +65,7 @@ int dns_answer_remove_by_rr(DnsAnswer **a, DnsResourceRecord *rr);
int dns_answer_copy_by_key(DnsAnswer **a, DnsAnswer *source, const DnsResourceKey *key, DnsAnswerFlags or_flags);
int dns_answer_move_by_key(DnsAnswer **to, DnsAnswer **from, const DnsResourceKey *key, DnsAnswerFlags or_flags);
-bool dns_answer_has_dname_for_cname(DnsAnswer *a, DnsResourceRecord *cname);
+int dns_answer_has_dname_for_cname(DnsAnswer *a, DnsResourceRecord *cname);
static inline size_t dns_answer_size(DnsAnswer *a) {
return a ? a->n_rrs : 0;
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index 23cd662fb8..403d23d4fb 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -680,13 +680,8 @@ int dns_cache_put(
/* Second, add in positive entries for all contained RRs */
DNS_ANSWER_FOREACH_FULL(rr, ifindex, flags, answer) {
- if ((flags & DNS_ANSWER_CACHEABLE) == 0)
- continue;
-
- r = rr_eligible(rr);
- if (r < 0)
- return r;
- if (r == 0)
+ if ((flags & DNS_ANSWER_CACHEABLE) == 0 ||
+ !rr_eligible(rr))
continue;
r = dns_cache_put_positive(
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index c921fe841f..746ff1b8be 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -554,17 +554,13 @@ static int dns_query_add_candidate(DnsQuery *q, DnsScope *s) {
return r;
/* If this a single-label domain on DNS, we might append a suitable search domain first. */
- if ((q->flags & SD_RESOLVED_NO_SEARCH) == 0) {
- r = dns_scope_name_needs_search_domain(s, dns_question_first_name(q->question_idna));
- if (r < 0)
- goto fail;
- if (r > 0) {
- /* OK, we need a search domain now. Let's find one for this scope */
+ if ((q->flags & SD_RESOLVED_NO_SEARCH) == 0 &&
+ dns_scope_name_needs_search_domain(s, dns_question_first_name(q->question_idna))) {
+ /* OK, we need a search domain now. Let's find one for this scope */
- r = dns_query_candidate_next_search_domain(c);
- if (r <= 0) /* if there's no search domain, then we won't add any transaction. */
- goto fail;
- }
+ r = dns_query_candidate_next_search_domain(c);
+ if (r <= 0) /* if there's no search domain, then we won't add any transaction. */
+ goto fail;
}
r = dns_query_candidate_setup_transactions(c);
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index c60b8215a6..5805546cf3 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -1380,10 +1380,7 @@ static int dns_transaction_prepare(DnsTransaction *t, usec_t ts) {
dns_transaction_stop_timeout(t);
- r = dns_scope_network_good(t->scope);
- if (r < 0)
- return r;
- if (r == 0) {
+ if (!dns_scope_network_good(t->scope)) {
dns_transaction_complete(t, DNS_TRANSACTION_NETWORK_DOWN);
return 0;
}
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index a4f2deba31..09e126d7f2 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -937,7 +937,7 @@ int bus_message_print_all_properties(
return log_oom();
r = set_put(*found_properties, name);
- if (r < 0 && r != EEXIST)
+ if (r < 0 && r != -EEXIST)
return log_oom();
}
diff --git a/src/shared/install.c b/src/shared/install.c
index 77ae812878..564f3aec2a 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -681,7 +681,7 @@ static int remove_marked_symlinks(
return r;
}
-static bool is_symlink_with_known_name(const UnitFileInstallInfo *i, const char *name) {
+static int is_symlink_with_known_name(const UnitFileInstallInfo *i, const char *name) {
int r;
if (streq(name, i->name))
diff --git a/src/shared/journal-util.h b/src/shared/journal-util.h
index 404fa53b30..da86434a67 100644
--- a/src/shared/journal-util.h
+++ b/src/shared/journal-util.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
#include <stdbool.h>
#include <sys/types.h>
diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c
index 53c5609f9b..4fedeb17e3 100644
--- a/src/shared/machine-pool.c
+++ b/src/shared/machine-pool.c
@@ -314,8 +314,7 @@ fail:
loop = safe_close(loop);
}
- if (control >= 0 && nr >= 0)
- (void) ioctl(control, LOOP_CTL_REMOVE, nr);
+ (void) ioctl(control, LOOP_CTL_REMOVE, nr);
return r;
}