int cfd;
r = fd_wait_for_event(fd, POLLIN, 0);
- if (r < 0) {
- if (r == -EINTR)
- continue;
-
+ if (r == -EINTR)
+ continue;
+ if (r < 0)
return r;
- }
if (r == 0)
return 0;
ssize_t l;
r = fd_wait_for_event(fd, POLLIN, /* timeout= */ 0);
- if (r < 0) {
- if (r == -EINTR)
- continue;
-
+ if (r == -EINTR)
+ continue;
+ if (r < 0)
return r;
- }
if (r == 0)
return count;
_cleanup_free_ char *s = NULL;
r = read_one_line_file(*vendor, &s);
- if (r < 0) {
- if (r == -ENOENT)
- continue;
-
+ if (r == -ENOENT)
+ continue;
+ if (r < 0)
return r;
- }
FOREACH_ELEMENT(dmi_vendor, dmi_vendor_table)
if (startswith(s, dmi_vendor->vendor)) {
assert(get_directory_func);
r = get_directory_func(&d);
- if (r < 0) {
- if (r == -ENXIO) /* Env var not set */
- return 0;
-
+ if (r == -ENXIO) /* Env var not set */
+ return 0;
+ if (r < 0)
return log_warning_errno(r, "Failed to determine %s directory: %m", title);
- }
r = readdir_all_at(AT_FDCWD, d, RECURSE_DIR_SORT|RECURSE_DIR_IGNORE_DOT, &de);
if (r < 0)
runtime_scope = ltype; /* otherwise, assume the scope is passed in via ltype */
r = parse_emergency_action(rvalue, runtime_scope, x);
- if (r < 0) {
- if (r == -EOPNOTSUPP)
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "%s= specified as %s mode action, ignoring: %s",
- lvalue, runtime_scope_to_string(runtime_scope), rvalue);
- else
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
- return 0;
- }
+ if (r == -EOPNOTSUPP)
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "%s= specified as %s mode action, ignoring: %s",
+ lvalue, runtime_scope_to_string(runtime_scope), rvalue);
+ else if (r < 0)
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
return 0;
}
int r;
r = manager_load_unit(m, name, NULL, NULL, &u);
- if (r < 0) {
- if (r == -ENOMEM)
- return r;
+ if (r == -ENOMEM)
+ return r;
+ if (r < 0)
return log_notice_errno(r, "Failed to load unit \"%s\", skipping deserialization: %m", name);
- }
r = unit_deserialize_state(u, f, fds);
- if (r < 0) {
- if (r == -ENOMEM)
- return r;
+ if (r == -ENOMEM)
+ return r;
+ if (r < 0)
return log_notice_errno(r, "Failed to deserialize unit \"%s\", skipping: %m", name);
- }
return 0;
}
case ACTION_ESCAPE:
if (arg_path) {
r = unit_name_path_escape(*i, &e);
- if (r < 0) {
- if (r == -EINVAL) {
- /* If escaping failed because the string was invalid, let's print a
- * friendly message about it. Catch these specific error cases
- * explicitly. */
-
- if (!path_is_valid(*i))
- return log_error_errno(r, "Input '%s' is not a valid file system path, failed to escape.", *i);
- if (!path_is_absolute(*i))
- return log_error_errno(r, "Input '%s' is not an absolute file system path, failed to escape.", *i);
- if (!path_is_normalized(*i))
- return log_error_errno(r, "Input '%s' is not a normalized file system path, failed to escape.", *i);
- }
-
+ if (r == -EINVAL) {
+ /* If escaping failed because the string was invalid, let's print a
+ * friendly message about it. Catch these specific error cases
+ * explicitly. */
+
+ if (!path_is_valid(*i))
+ return log_error_errno(r, "Input '%s' is not a valid file system path, failed to escape.", *i);
+ if (!path_is_absolute(*i))
+ return log_error_errno(r, "Input '%s' is not an absolute file system path, failed to escape.", *i);
+ if (!path_is_normalized(*i))
+ return log_error_errno(r, "Input '%s' is not a normalized file system path, failed to escape.", *i);
+ }
+ if (r < 0)
/* All other error cases. */
return log_error_errno(r, "Failed to escape string: %m");
- }
/* If the escaping worked, then still warn if the path is not like we'd like
* it. Because that means escaping is not necessarily reversible. */
char *d;
r = keyring_describe(*key, &description);
- if (r < 0) {
- if (r == -ENOKEY) /* Something else deleted it already, that's ok. */
- continue;
-
+ if (r == -ENOKEY) /* Something else deleted it already, that's ok. */
+ continue;
+ if (r < 0)
return log_error_errno(r, "Failed to describe key id %d: %m", *key);
- }
/* The description is the final element as per manpage. */
d = strrchr(description, ';');
0,
LOCK_EX,
&setup->loop);
- if (r < 0) {
- if (r == -ENOENT) { /* this means /dev/loop-control doesn't exist, i.e. we are in a container
- * or similar and loopback bock devices are not available, return a
- * recognizable error in this case. */
- log_error_errno(r, "Loopback block device support is not available on this system.");
- return -ENOLINK; /* Make recognizable */
- }
-
+ if (r == -ENOENT) /* this means /dev/loop-control doesn't exist, i.e. we are in a container
+ * or similar and loopback bock devices are not available, return a
+ * recognizable error in this case. */
+ return log_error_errno(SYNTHETIC_ERRNO(ENOLINK), "Loopback block device support is not available on this system.");
+ if (r < 0)
return log_error_errno(r, "Failed to set up loopback device for %s: %m", setup->temporary_image_path);
- }
log_info("Setting up loopback device %s completed.", setup->loop->node ?: ip);
assert(filename);
r = read_full_file(filename, &db, &db_len);
- if (r < 0) {
- if (r == -ENOENT)
- return 0;
-
+ if (r == -ENOENT)
+ return 0;
+ if (r < 0)
return log_device_debug_errno(device, r, "sd-device: Failed to read db '%s': %m", filename);
- }
/* devices with a database entry are initialized */
device->is_initialized = true;
return 0;
r = efi_loader_get_entries(&m->efi_boot_loader_entries);
- if (r < 0) {
- if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r)) {
- log_debug_errno(r, "Boot loader reported no entries.");
- m->efi_boot_loader_entries_set = true;
- return 0;
- }
- return log_error_errno(r, "Failed to determine entries reported by boot loader: %m");
+ if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r)) {
+ log_debug_errno(r, "Boot loader reported no entries.");
+ m->efi_boot_loader_entries_set = true;
+ return 0;
}
+ if (r < 0)
+ return log_error_errno(r, "Failed to determine entries reported by boot loader: %m");
m->efi_boot_loader_entries_set = true;
return 1;
if (elapse == USEC_INFINITY) {
if (m->maintenance_time) {
r = calendar_spec_next_usec(m->maintenance_time, now(CLOCK_REALTIME), &elapse);
- if (r < 0) {
- if (r == -ENOENT)
- return sd_bus_error_set(error,
- BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED,
- "No upcoming maintenance window scheduled");
-
+ if (r == -ENOENT)
+ return sd_bus_error_set(error,
+ BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED,
+ "No upcoming maintenance window scheduled");
+ if (r < 0)
return sd_bus_error_set_errnof(error, r,
"Failed to determine next maintenance window: %m");
- }
log_info("Scheduled %s at maintenance window %s", type, FORMAT_TIMESTAMP(elapse));
} else
switch (arg_append_fstab) {
case APPEND_AUTO: {
r = read_full_file(path, &c, NULL);
- if (r < 0) {
- if (r == -ENOENT) {
- log_debug("File fstab not found in %s", path);
- break;
- }
- return log_error_errno(r, "Failed to open %s: %m", path);
+ if (r == -ENOENT) {
+ log_debug("File fstab not found in %s", path);
+ break;
}
+ if (r < 0)
+ return log_error_errno(r, "Failed to open %s: %m", path);
const char *acs, *ace;
acs = find_line(c, AUTOMATIC_FSTAB_HEADER_START);
return 0;
r = efi_get_variable_string(EFI_SYSTEMD_VARIABLE_STR("FactoryReset"), &value);
- if (r < 0) {
- if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
- return 0;
+ if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
+ return 0;
+ if (r < 0)
return log_error_errno(r, "Failed to read EFI variable FactoryReset: %m");
- }
log_warning("Warning, EFI variable FactoryReset is in use, please migrate to use FactoryResetRequest instead, support will be removed in v260!");
// FIXME: Remove this in v260, see above
r = efi_set_variable(EFI_SYSTEMD_VARIABLE_STR("FactoryReset"), NULL, 0);
- if (r < 0) {
- if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
- return 0;
+ if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
+ return 0;
+ if (r < 0)
return log_error_errno(r, "Failed to remove EFI variable FactoryReset: %m");
- }
log_info("Successfully unset EFI variable FactoryReset.");
return 0;
return log_device_warning_errno(dev, r, "Failed to get link information: %m");
r = link_get_config(ctx, link);
- if (r < 0) {
- if (r == -ENOENT) {
- log_device_debug_errno(dev, r, "No matching link configuration found, ignoring device.");
- return 0;
- }
-
- return log_device_error_errno(dev, r, "Failed to get link config: %m");
+ if (r == -ENOENT) {
+ log_device_debug_errno(dev, r, "No matching link configuration found, ignoring device.");
+ return 0;
}
+ if (r < 0)
+ return log_device_error_errno(dev, r, "Failed to get link config: %m");
r = link_apply_config(ctx, link);
if (r == -ENODEV)