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),
"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;
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);
if (r < 0)
return r;
- v->allow_fd_passing_output = !!b;
+ v->allow_fd_passing_output = b;
return 1;
}
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");
- }
}
}
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);
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)
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) {
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);
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,
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;
}
}
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");
if (!h)
return NULL;
- mfree(h->socket_path);
+ free(h->socket_path);
sd_varlink_unref(h->filter_link);
set_free(h->idle_links);
param->key = key;
param->length = len;
- if (value != NULL)
+ if (value)
memcpy(param->value, value, len);
LIST_APPEND(params, rr->svcb.params, param);
param->key = key;
param->length = len;
- if (value != NULL)
+ if (value)
memcpy(param->value, value, len);
LIST_APPEND(params, rr->svcb.params, param);
ASSERT_NOT_NULL(query);
ASSERT_TRUE(dns_query_go(query));
- if (check_query != NULL)
+ if (check_query)
check_query(query);
}
param->key = key;
param->length = len;
- if (value != NULL)
+ if (value)
memcpy(param->value, value, len);
LIST_APPEND(params, rr->svcb.params, param);
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;
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++;
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"
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;
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;
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;
(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(
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