tree-wide: various fixlets suggested by Coccinelle
This commit is contained in:
@@ -1150,10 +1150,8 @@ int flush_accept(int fd) {
|
||||
r = fd_wait_for_event(fd, POLLIN, 0);
|
||||
if (r == -EINTR)
|
||||
continue;
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
if (iteration >= MAX_FLUSH_ITERATIONS)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBUSY),
|
||||
|
||||
+1
-2
@@ -454,8 +454,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
"64 hex character SHA256 hash required when specifying explicit checksum, %zu specified", n * 2);
|
||||
|
||||
iovec_done(&arg_checksum);
|
||||
arg_checksum.iov_base = TAKE_PTR(h);
|
||||
arg_checksum.iov_len = n;
|
||||
arg_checksum = IOVEC_MAKE(TAKE_PTR(h), n);
|
||||
|
||||
arg_import_flags &= ~(IMPORT_PULL_SETTINGS|IMPORT_PULL_ROOTHASH|IMPORT_PULL_ROOTHASH_SIGNATURE|IMPORT_PULL_VERITY);
|
||||
arg_verify = _IMPORT_VERIFY_INVALID;
|
||||
|
||||
@@ -68,7 +68,7 @@ static int test_basic(bool bind_to_interface) {
|
||||
r = sd_dhcp_server_start(server);
|
||||
/* skip test if running in an environment with no full networking support, CONFIG_PACKET not
|
||||
* compiled in kernel, nor af_packet module available. */
|
||||
if (r == -EPERM || r == -EAFNOSUPPORT)
|
||||
if (IN_SET(r, -EPERM, -EAFNOSUPPORT))
|
||||
return r;
|
||||
ASSERT_OK(r);
|
||||
|
||||
|
||||
@@ -3411,7 +3411,7 @@ _public_ int sd_varlink_set_allow_fd_passing_output(sd_varlink *v, int b) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
v->allow_fd_passing_output = !!b;
|
||||
v->allow_fd_passing_output = b;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,9 +105,8 @@ static void sd_eviocrevoke(int fd) {
|
||||
if (errno == EINVAL) {
|
||||
log_warning_errno(errno, "Kernel does not support evdev-revocation, continuing without revoking device access: %m");
|
||||
warned = true;
|
||||
} else if (errno != ENODEV) {
|
||||
} else if (errno != ENODEV)
|
||||
log_warning_errno(errno, "Failed to revoke evdev device, continuing without revoking device access: %m");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -316,10 +316,8 @@ static int machine_add_from_params(
|
||||
details,
|
||||
&manager->polkit_registry,
|
||||
error);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return 0; /* Will call us back */
|
||||
if (r <= 0)
|
||||
return r; /* 0 means Polkit will call us back, see method_create_machine() */
|
||||
}
|
||||
|
||||
r = manager_add_machine(manager, name, &m);
|
||||
|
||||
@@ -1321,10 +1321,8 @@ static int acquire_removable(sd_device *d) {
|
||||
return r;
|
||||
|
||||
r = device_in_subsystem(d, "block");
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parse_boolean(v) <= 0)
|
||||
|
||||
@@ -1439,12 +1439,11 @@ void netdev_dump(NetDev *netdev, FILE *f) {
|
||||
if (netdev->mtu > 0)
|
||||
fprintf(f, "MTUBytes=%" PRIu32 "\n", netdev->mtu);
|
||||
|
||||
if (streq(netdev->kind, "vlan")) {
|
||||
if (streq(netdev->kind, "vlan"))
|
||||
fprintf(f,
|
||||
"\n[VLAN]\n"
|
||||
"Id=%u\n",
|
||||
netdev->vlan_id);
|
||||
}
|
||||
}
|
||||
|
||||
void link_dump(Link *link, FILE *f) {
|
||||
|
||||
@@ -152,11 +152,8 @@ Modem* modem_free(Modem *modem) {
|
||||
if (!modem)
|
||||
return NULL;
|
||||
|
||||
if (modem->bearers_by_name)
|
||||
hashmap_free(modem->bearers_by_name);
|
||||
|
||||
if (modem->bearers_by_path)
|
||||
hashmap_free(modem->bearers_by_path);
|
||||
hashmap_free(modem->bearers_by_name);
|
||||
hashmap_free(modem->bearers_by_path);
|
||||
|
||||
if (modem->manager)
|
||||
hashmap_remove_value(modem->manager->modems_by_path, modem->path, modem);
|
||||
|
||||
@@ -422,7 +422,7 @@ static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to select any cgroups based on swap: %m");
|
||||
else {
|
||||
if (selected && r > 0) {
|
||||
if (selected && r > 0)
|
||||
log_notice("Marked %s for killing due to memory used (%"PRIu64") / total (%"PRIu64") and "
|
||||
"swap used (%"PRIu64") / total (%"PRIu64") being more than "
|
||||
PERMYRIAD_AS_PERCENT_FORMAT_STR,
|
||||
@@ -430,7 +430,6 @@ static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void
|
||||
m->system_context.mem_used, m->system_context.mem_total,
|
||||
m->system_context.swap_used, m->system_context.swap_total,
|
||||
PERMYRIAD_AS_PERCENT_FORMAT_VAL(m->swap_used_limit_permyriad));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,9 +441,9 @@ int mdns_manage_services_answer(DnsServiceBrowser *sb, DnsAnswer *answer, int ow
|
||||
browse_service_update_event_to_string(
|
||||
BROWSE_SERVICE_UPDATE_REMOVED)),
|
||||
SD_JSON_BUILD_PAIR_INTEGER("family", owner_family),
|
||||
SD_JSON_BUILD_PAIR_STRING("name", name ?: ""),
|
||||
SD_JSON_BUILD_PAIR_STRING("type", type ?: ""),
|
||||
SD_JSON_BUILD_PAIR_STRING("domain", domain ?: ""),
|
||||
SD_JSON_BUILD_PAIR_STRING("name", strempty(name)),
|
||||
SD_JSON_BUILD_PAIR_STRING("type", strempty(type)),
|
||||
SD_JSON_BUILD_PAIR_STRING("domain", strempty(domain)),
|
||||
SD_JSON_BUILD_PAIR_INTEGER("ifindex", ifindex));
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to build JSON for removed service: %m");
|
||||
|
||||
@@ -49,7 +49,7 @@ static Hook* hook_free(Hook *h) {
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
mfree(h->socket_path);
|
||||
free(h->socket_path);
|
||||
sd_varlink_unref(h->filter_link);
|
||||
set_free(h->idle_links);
|
||||
|
||||
|
||||
@@ -1180,7 +1180,7 @@ static DnsSvcParam* add_svcb_param(DnsResourceRecord *rr, uint16_t key, const ch
|
||||
param->key = key;
|
||||
param->length = len;
|
||||
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
memcpy(param->value, value, len);
|
||||
|
||||
LIST_APPEND(params, rr->svcb.params, param);
|
||||
|
||||
@@ -3902,7 +3902,7 @@ static DnsSvcParam* add_svcb_param(DnsResourceRecord *rr, uint16_t key, const ch
|
||||
param->key = key;
|
||||
param->length = len;
|
||||
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
memcpy(param->value, value, len);
|
||||
|
||||
LIST_APPEND(params, rr->svcb.params, param);
|
||||
|
||||
@@ -858,7 +858,7 @@ static void exercise_dns_query_go(GoConfig *cfg, void (*check_query)(DnsQuery *q
|
||||
ASSERT_NOT_NULL(query);
|
||||
ASSERT_TRUE(dns_query_go(query));
|
||||
|
||||
if (check_query != NULL)
|
||||
if (check_query)
|
||||
check_query(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -2043,7 +2043,7 @@ static DnsSvcParam* add_svcb_param(DnsResourceRecord *rr, uint16_t key, const ch
|
||||
param->key = key;
|
||||
param->length = len;
|
||||
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
memcpy(param->value, value, len);
|
||||
|
||||
LIST_APPEND(params, rr->svcb.params, param);
|
||||
|
||||
@@ -2187,10 +2187,8 @@ int image_setup_pool(RuntimeScope scope, ImageClass class, bool use_btrfs_subvol
|
||||
return r;
|
||||
|
||||
r = check_btrfs(pool);
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
if (!use_btrfs_subvol)
|
||||
return 0;
|
||||
|
||||
@@ -284,8 +284,8 @@ int hostname_substitute_wildcards(char *name) {
|
||||
|
||||
struct siphash state;
|
||||
siphash24_init(&state, key.bytes);
|
||||
siphash24_compress(&mid, sizeof(mid), &state);
|
||||
siphash24_compress(&counter, sizeof(counter), &state); /* counter mode */
|
||||
siphash24_compress_typesafe(mid, &state);
|
||||
siphash24_compress_typesafe(counter, &state); /* counter mode */
|
||||
h = siphash24_finalize(&state);
|
||||
left_bits = sizeof(h) * 8;
|
||||
counter++;
|
||||
|
||||
@@ -1244,7 +1244,7 @@ int fido2_list_devices(void) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (table_get_rows(t) > 1)
|
||||
if (!table_isempty(t))
|
||||
printf("\n"
|
||||
"%1$sLegend: RK %2$s Resident key%3$s\n"
|
||||
"%1$s CLIENTPIN %2$s PIN request%3$s\n"
|
||||
|
||||
@@ -95,7 +95,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case ARG_ISSUE_PATH:
|
||||
if (isempty(optarg) || streq(optarg, "-")) {
|
||||
if (empty_or_dash(optarg)) {
|
||||
arg_issue_path = mfree(arg_issue_path);
|
||||
arg_issue_stdout = true;
|
||||
break;
|
||||
|
||||
@@ -108,14 +108,13 @@ static int parse_shutdown_time_spec(const char *t, usec_t *ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (tm.tm_hour != requested_hour || tm.tm_min != requested_min) {
|
||||
if (tm.tm_hour != requested_hour || tm.tm_min != requested_min)
|
||||
log_warning("Requested shutdown time %02d:%02d does not exist. "
|
||||
"Rescheduling to %02d:%02d.",
|
||||
requested_hour,
|
||||
requested_min,
|
||||
tm.tm_hour,
|
||||
tm.tm_min);
|
||||
}
|
||||
}
|
||||
|
||||
*ret = s;
|
||||
|
||||
@@ -397,13 +397,12 @@ static int context_discover_update_sets_by_flag(Context *c, UpdateSetFlags flags
|
||||
assert(flags == UPDATE_INSTALLED);
|
||||
|
||||
match = resource_find_instance(&t->target, cursor);
|
||||
if (!match && !(extra_flags & (UPDATE_PARTIAL|UPDATE_PENDING))) {
|
||||
if (!match && !(extra_flags & (UPDATE_PARTIAL|UPDATE_PENDING)))
|
||||
/* When we're looking for installed versions, let's be robust and treat
|
||||
* an incomplete installation as an installation. Otherwise, there are
|
||||
* situations that can lead to sysupdate wiping the currently booted OS.
|
||||
* See https://github.com/systemd/systemd/issues/33339 */
|
||||
extra_flags |= UPDATE_INCOMPLETE;
|
||||
}
|
||||
}
|
||||
|
||||
cursor_instances[k] = match;
|
||||
|
||||
@@ -192,7 +192,7 @@ static int verb_probe(UdevEvent *event, sd_device *dev) {
|
||||
(void) image_policy_to_string(image_policy, /* simplify= */ false, &a);
|
||||
(void) image_policy_to_string(image_policy_mangled, /* simplify= */ false, &b);
|
||||
|
||||
log_device_debug_errno(dev, ERFKILL, "Couldn't dissect block device with regular policy '%s', retrying with policy where root/usr are set to ignore '%s'.", a, b);
|
||||
log_device_debug_errno(dev, SYNTHETIC_ERRNO(ERFKILL), "Couldn't dissect block device with regular policy '%s', retrying with policy where root/usr are set to ignore '%s'.", a, b);
|
||||
}
|
||||
|
||||
r = dissect_loop_device(
|
||||
|
||||
@@ -157,10 +157,8 @@ static int worker_mark_block_device_read_only(sd_device *dev) {
|
||||
return 0;
|
||||
|
||||
r = device_in_subsystem(dev, "block");
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
/* Exclude synthetic devices for now, this is supposed to be a safety feature to avoid modification
|
||||
* of physical devices, and what sits on top of those doesn't really matter if we don't allow the
|
||||
|
||||
Reference in New Issue
Block a user