Merge pull request #9398 from yuwata/lgtm-fixes
fixes error handlings and several cleanups suggested by LGTM
This commit is contained in:
commit
2919425bab
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#if HAVE_LIBCRYPTSETUP
|
||||
#include <libcryptsetup.h>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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... */
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "hashmap.h"
|
||||
#include "machine-image.h"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
int resolvconf_parse_argv(int argc, char *argv[]);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <in-addr-util.h>
|
||||
#include <stdbool.h>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue