diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 23:40:44 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-22 10:54:38 +0100 |
commit | baaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch) | |
tree | bb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/shared | |
parent | basic/log: add concept of "synthethic errnos" (diff) | |
download | systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.tar.xz systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.zip |
coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.
I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/bootspec.c | 15 | ||||
-rw-r--r-- | src/shared/bus-unit-util.c | 88 | ||||
-rw-r--r-- | src/shared/bus-util.c | 8 | ||||
-rw-r--r-- | src/shared/dissect-image.c | 7 | ||||
-rw-r--r-- | src/shared/dropin.c | 8 | ||||
-rw-r--r-- | src/shared/efivars.c | 7 | ||||
-rw-r--r-- | src/shared/generator.c | 24 | ||||
-rw-r--r-- | src/shared/install.c | 15 | ||||
-rw-r--r-- | src/shared/journal-importer.c | 33 | ||||
-rw-r--r-- | src/shared/logs-show.c | 49 | ||||
-rw-r--r-- | src/shared/seccomp-util.c | 8 | ||||
-rw-r--r-- | src/shared/serialize.c | 8 | ||||
-rw-r--r-- | src/shared/sleep-config.c | 4 | ||||
-rw-r--r-- | src/shared/verbs.c | 14 |
14 files changed, 134 insertions, 154 deletions
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 9ba6978962..db4fd411e2 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -593,10 +593,10 @@ int find_esp_and_warn( path = getenv("SYSTEMD_ESP_PATH"); if (path) { - if (!path_is_valid(path) || !path_is_absolute(path)) { - log_error("$SYSTEMD_ESP_PATH does not refer to absolute path, refusing to use it: %s", path); - return -EINVAL; - } + if (!path_is_valid(path) || !path_is_absolute(path)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "$SYSTEMD_ESP_PATH does not refer to absolute path, refusing to use it: %s", + path); /* Note: when the user explicitly configured things with an env var we won't validate the mount * point. After all we want this to be useful for testing. */ @@ -649,10 +649,9 @@ int find_default_boot_entry( if (r < 0) return log_error_errno(r, "Failed to load bootspec config from \"%s/loader\": %m", where); - if (config->default_entry < 0) { - log_error("No entry suitable as default, refusing to guess."); - return -ENOENT; - } + if (config->default_entry < 0) + return log_error_errno(SYNTHETIC_ERRNO(ENOENT), + "No entry suitable as default, refusing to guess."); *e = &config->entries[config->default_entry]; log_debug("Found default boot entry in file \"%s\"", (*e)->path); diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 2cd30e3467..0141c131f6 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -83,10 +83,8 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { int r; \ \ r = parse_func(eq); \ - if (r < 0) { \ - log_error("Failed to parse %s: %s", field, eq); \ - return -EINVAL; \ - } \ + if (r < 0) \ + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse %s: %s", field, eq); \ \ r = sd_bus_message_append(m, "(sv)", field, \ bus_type, (int32_t) r); \ @@ -277,8 +275,8 @@ static int bus_append_exec_command(sd_bus_message *m, const char *field, const c case '+': case '!': /* The bus API doesn't support +, ! and !! currently, unfortunately. :-( */ - log_error("Sorry, but +, ! and !! are currently not supported for transient services."); - return -EOPNOTSUPP; + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), + "Sorry, but +, ! and !! are currently not supported for transient services."); default: done = true; @@ -450,10 +448,9 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", USEC_INFINITY); else { r = parse_permille_unbounded(eq); - if (r == 0) { - log_error("CPU quota too small."); - return -ERANGE; - } + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(ERANGE), + "CPU quota too small."); if (r < 0) return log_error_errno(r, "CPU quota '%s' invalid.", eq); @@ -497,10 +494,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons uint64_t bytes; e = strchr(eq, ' '); - if (!e) { - log_error("Failed to parse %s value %s.", field, eq); - return -EINVAL; - } + if (!e) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse %s value %s.", + field, eq); path = strndupa(eq, e - eq); bandwidth = e+1; @@ -531,10 +528,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons uint64_t u; e = strchr(eq, ' '); - if (!e) { - log_error("Failed to parse %s value %s.", field, eq); - return -EINVAL; - } + if (!e) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse %s value %s.", + field, eq); path = strndupa(eq, e - eq); weight = e+1; @@ -562,10 +559,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons usec_t usec; e = strchr(eq, ' '); - if (!e) { - log_error("Failed to parse %s value %s.", field, eq); - return -EINVAL; - } + if (!e) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse %s value %s.", + field, eq); path = strndupa(eq, e - eq); target = e+1; @@ -1125,10 +1122,10 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con r = extract_first_word(&p, &destination, ":" WHITESPACE, EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS); if (r < 0) return log_error_errno(r, "Failed to parse argument: %m"); - if (r == 0) { - log_error("Missing argument after ':': %s", eq); - return -EINVAL; - } + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Missing argument after ':': %s", + eq); d = destination; @@ -1143,10 +1140,10 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con flags = MS_REC; else if (streq(options, "norbind")) flags = 0; - else { - log_error("Unknown options: %s", eq); - return -EINVAL; - } + else + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Unknown options: %s", + eq); } } else d = s; @@ -1204,10 +1201,10 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS); if (r < 0) return log_error_errno(r, "Failed to parse argument: %m"); - if (r == 0) { - log_error("Failed to parse argument: %s", p); - return -EINVAL; - } + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse argument: %s", + p); r = sd_bus_message_append(m, "(ss)", path, w); if (r < 0) @@ -1603,10 +1600,9 @@ int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const cha assert(assignment); eq = strchr(assignment, '='); - if (!eq) { - log_error("Not an assignment: %s", assignment); - return -EINVAL; - } + if (!eq) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Not an assignment: %s", assignment); field = strndupa(assignment, eq - assignment); eq++; @@ -1709,20 +1705,20 @@ int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const cha case UNIT_TARGET: case UNIT_DEVICE: case UNIT_SWAP: - log_error("Not supported unit type"); - return -EINVAL; + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Not supported unit type"); default: - log_error("Invalid unit type"); - return -EINVAL; + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Invalid unit type"); } r = bus_append_unit_property(m, field, eq); if (r != 0) return r; - log_error("Unknown assignment: %s", assignment); - return -EINVAL; + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Unknown assignment: %s", assignment); } int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char **l) { @@ -2006,8 +2002,8 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet, const char* const* else if (STR_IN_SET(d->result, "done", "skipped")) return 0; - log_debug("Unexpected job result, assuming server side newer than us: %s", d->result); - return -EIO; + return log_debug_errno(SYNTHETIC_ERRNO(EIO), + "Unexpected job result, assuming server side newer than us: %s", d->result); } int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_args) { diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 4667d3bc52..760be38c85 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -1382,12 +1382,10 @@ int bus_connect_transport_systemd(BusTransport transport, const char *host, bool if (user) r = bus_connect_user_systemd(bus); else { - if (sd_booted() <= 0) { + if (sd_booted() <= 0) /* Print a friendly message when the local system is actually not running systemd as PID 1. */ - log_error("System has not been booted with systemd as init system (PID 1). Can't operate."); - - return -EHOSTDOWN; - } + return log_error_errno(SYNTHETIC_ERRNO(EHOSTDOWN), + "System has not been booted with systemd as init system (PID 1). Can't operate."); r = bus_connect_system_systemd(bus); } break; diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index ec3e1a10bb..18620a3b19 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -1086,10 +1086,9 @@ int dissected_image_decrypt_interactively( else if (r != -ENOKEY) return log_error_errno(r, "Failed to decrypt image: %m"); - if (--n < 0) { - log_error("Too many retries."); - return -EKEYREJECTED; - } + if (--n < 0) + return log_error_errno(SYNTHETIC_ERRNO(EKEYREJECTED), + "Too many retries."); z = strv_free(z); diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 357c66d800..409eef21ff 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -204,10 +204,10 @@ static int unit_file_find_dirs( return 0; type = unit_name_to_type(name); - if (type < 0) { - log_error("Failed to to derive unit type from unit name: %s", name); - return -EINVAL; - } + if (type < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to to derive unit type from unit name: %s", + name); if (is_instance) { r = unit_name_to_instance(name, &instance); diff --git a/src/shared/efivars.c b/src/shared/efivars.c index 6815fc69b8..cb9e13c15f 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -875,10 +875,9 @@ int efi_loader_get_features(uint64_t *ret) { if (r < 0) return r; - if (s != sizeof(uint64_t)) { - log_debug("LoaderFeatures EFI variable doesn't have the right size."); - return -EINVAL; - } + if (s != sizeof(uint64_t)) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "LoaderFeatures EFI variable doesn't have the right size."); memcpy(ret, v, sizeof(uint64_t)); return 0; diff --git a/src/shared/generator.c b/src/shared/generator.c index eba0ae8ae0..e4a15f8b11 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -310,10 +310,10 @@ int generator_hook_up_mkswap( return log_oom(); /* Nothing to work on. */ - if (!is_device_path(node)) { - log_error("Cannot format something that is not a device node: %s", node); - return -EINVAL; - } + if (!is_device_path(node)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Cannot format something that is not a device node: %s", + node); r = unit_name_from_path_instance("systemd-mkswap", node, ".service", &unit); if (r < 0) @@ -380,15 +380,15 @@ int generator_hook_up_mkfs( return log_oom(); /* Nothing to work on. */ - if (!is_device_path(node)) { - log_error("Cannot format something that is not a device node: %s", node); - return -EINVAL; - } + if (!is_device_path(node)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Cannot format something that is not a device node: %s", + node); - if (!type || streq(type, "auto")) { - log_error("Cannot format partition %s, filesystem type is not specified", node); - return -EINVAL; - } + if (!type || streq(type, "auto")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Cannot format partition %s, filesystem type is not specified", + node); r = unit_name_from_path_instance("systemd-mkfs", node, ".service", &unit); if (r < 0) diff --git a/src/shared/install.c b/src/shared/install.c index 1fd24cb4eb..97c48afe5d 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1232,10 +1232,9 @@ static int unit_file_load( type = unit_name_to_type(info->name); if (type < 0) return -EINVAL; - if (unit_name_is_valid(info->name, UNIT_NAME_TEMPLATE|UNIT_NAME_INSTANCE) && !unit_type_may_template(type)) { - log_error("Unit type %s cannot be templated.", unit_type_to_string(type)); - return -EINVAL; - } + if (unit_name_is_valid(info->name, UNIT_NAME_TEMPLATE|UNIT_NAME_INSTANCE) && !unit_type_may_template(type)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Unit type %s cannot be templated.", unit_type_to_string(type)); if (!(flags & SEARCH_LOAD)) { r = lstat(path, &st); @@ -1448,10 +1447,10 @@ static int unit_file_search( } } - if (!found_unit) { - log_debug("Cannot find unit %s%s%s.", info->name, template ? " or " : "", strempty(template)); - return -ENOENT; - } + if (!found_unit) + return log_debug_errno(SYNTHETIC_ERRNO(ENOENT), + "Cannot find unit %s%s%s.", + info->name, template ? " or " : "", strempty(template)); if (info->type == UNIT_FILE_TYPE_MASKED) return result; diff --git a/src/shared/journal-importer.c b/src/shared/journal-importer.c index ca203bbbfc..b0e619205d 100644 --- a/src/shared/journal-importer.c +++ b/src/shared/journal-importer.c @@ -96,10 +96,10 @@ static int get_line(JournalImporter *imp, char **line, size_t *size) { } imp->scanned = imp->filled; - if (imp->scanned >= DATA_SIZE_MAX) { - log_error("Entry is bigger than %u bytes.", DATA_SIZE_MAX); - return -E2BIG; - } + if (imp->scanned >= DATA_SIZE_MAX) + return log_error_errno(SYNTHETIC_ERRNO(E2BIG), + "Entry is bigger than %u bytes.", + DATA_SIZE_MAX); if (imp->passive_fd) /* we have to wait for some data to come to us */ @@ -192,11 +192,10 @@ static int get_data_size(JournalImporter *imp) { return r; imp->data_size = unaligned_read_le64(data); - if (imp->data_size > DATA_SIZE_MAX) { - log_error("Stream declares field with size %zu > DATA_SIZE_MAX = %u", - imp->data_size, DATA_SIZE_MAX); - return -EINVAL; - } + if (imp->data_size > DATA_SIZE_MAX) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Stream declares field with size %zu > DATA_SIZE_MAX = %u", + imp->data_size, DATA_SIZE_MAX); if (imp->data_size == 0) log_warning("Binary field with zero length"); @@ -234,8 +233,8 @@ static int get_data_newline(JournalImporter *imp) { int l; l = cescape_char(*data, buf); - log_error("Expected newline, got '%.*s'", l, buf); - return -EINVAL; + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Expected newline, got '%.*s'", l, buf); } return 1; @@ -446,12 +445,12 @@ int journal_importer_push_data(JournalImporter *imp, const char *data, size_t si assert(imp); assert(imp->state != IMPORTER_STATE_EOF); - if (!realloc_buffer(imp, imp->filled + size)) { - log_error("Failed to store received data of size %zu " - "(in addition to existing %zu bytes with %zu filled): %s", - size, imp->size, imp->filled, strerror(ENOMEM)); - return -ENOMEM; - } + if (!realloc_buffer(imp, imp->filled + size)) + return log_error_errno(SYNTHETIC_ERRNO(ENOMEM), + "Failed to store received data of size %zu " + "(in addition to existing %zu bytes with %zu filled): %s", + size, imp->size, imp->filled, + strerror(ENOMEM)); memcpy(imp->buf + imp->filled, data, size); imp->filled += size; diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 2d53307203..41d484fa16 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -303,10 +303,9 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou k = format_timestamp_utc(buf, sizeof(buf), x); else k = format_timestamp(buf, sizeof(buf), x); - if (!k) { - log_error("Failed to format timestamp: %"PRIu64, x); - return -EINVAL; - } + if (!k) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to format timestamp: %" PRIu64, x); } else { char usec[7]; @@ -321,18 +320,16 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou break; case OUTPUT_SHORT_ISO: - if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", gettime_r(&t, &tm)) <= 0) { - log_error("Failed to format ISO time"); - return -EINVAL; - } + if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", gettime_r(&t, &tm)) <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to format ISO time"); break; case OUTPUT_SHORT_ISO_PRECISE: /* No usec in strftime, so we leave space and copy over */ - if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.xxxxxx%z", gettime_r(&t, &tm)) <= 0) { - log_error("Failed to format ISO-precise time"); - return -EINVAL; - } + if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.xxxxxx%z", gettime_r(&t, &tm)) <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to format ISO-precise time"); xsprintf(usec, "%06"PRI_USEC, x % USEC_PER_SEC); memcpy(buf + 20, usec, 6); break; @@ -340,10 +337,9 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou case OUTPUT_SHORT: case OUTPUT_SHORT_PRECISE: - if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", gettime_r(&t, &tm)) <= 0) { - log_error("Failed to format syslog time"); - return -EINVAL; - } + if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", gettime_r(&t, &tm)) <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to format syslog time"); if (mode == OUTPUT_SHORT_PRECISE) { size_t k; @@ -352,10 +348,9 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou k = sizeof(buf) - strlen(buf); r = snprintf(buf + strlen(buf), k, ".%06"PRIu64, x % USEC_PER_SEC); - if (r <= 0 || (size_t) r >= k) { /* too long? */ - log_error("Failed to format precise time"); - return -EINVAL; - } + if (r <= 0 || (size_t) r >= k) /* too long? */ + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to format precise time"); } break; @@ -563,10 +558,9 @@ static int output_verbose( const char *on = "", *off = ""; c = memchr(data, '=', length); - if (!c) { - log_error("Invalid field."); - return -EINVAL; - } + if (!c) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Invalid field."); fieldlen = c - (const char*) data; r = field_set_test(output_fields, data, fieldlen); @@ -658,10 +652,9 @@ static int output_export( continue; c = memchr(data, '=', length); - if (!c) { - log_error("Invalid field."); - return -EINVAL; - } + if (!c) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Invalid field."); r = field_set_test(output_fields, data, c - (const char *) data); if (r < 0) diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index e00001288d..67ccd43c3f 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -874,10 +874,10 @@ int seccomp_add_syscall_filter_item(scmp_filter_ctx *seccomp, const char *name, const SyscallFilterSet *other; other = syscall_filter_set_find(name); - if (!other) { - log_debug("Filter set %s is not known!", name); - return -EINVAL; - } + if (!other) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "Filter set %s is not known!", + name); return seccomp_add_syscall_filter_set(seccomp, other, action, exclude, log_missing); diff --git a/src/shared/serialize.c b/src/shared/serialize.c index d0f86a83f4..eb1191b3bf 100644 --- a/src/shared/serialize.c +++ b/src/shared/serialize.c @@ -153,10 +153,10 @@ int deserialize_dual_timestamp(const char *value, dual_timestamp *t) { return -EINVAL; r = sscanf(value, "%" PRIu64 "%" PRIu64 "%n", &a, &b, &pos); - if (r != 2) { - log_debug("Failed to parse dual timestamp value \"%s\".", value); - return -EINVAL; - } + if (r != 2) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse dual timestamp value \"%s\".", + value); if (value[pos] != '\0') /* trailing garbage */ diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 62fd3655e9..9ea88a37b4 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -256,8 +256,8 @@ int find_hibernate_location(char **device, char **type, size_t *size, size_t *us return 0; } - log_debug("No swap partitions were found."); - return -ENOSYS; + return log_debug_errno(SYNTHETIC_ERRNO(ENOSYS), + "No swap partitions were found."); } static bool enough_swap_for_hibernation(void) { diff --git a/src/shared/verbs.c b/src/shared/verbs.c index f68c2bae08..7c5dcb02a2 100644 --- a/src/shared/verbs.c +++ b/src/shared/verbs.c @@ -92,16 +92,14 @@ int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata) { left = 1; if (verb->min_args != VERB_ANY && - (unsigned) left < verb->min_args) { - log_error("Too few arguments."); - return -EINVAL; - } + (unsigned) left < verb->min_args) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Too few arguments."); if (verb->max_args != VERB_ANY && - (unsigned) left > verb->max_args) { - log_error("Too many arguments."); - return -EINVAL; - } + (unsigned) left > verb->max_args) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Too many arguments."); if ((verb->flags & VERB_ONLINE_ONLY) && running_in_chroot_or_offline()) { if (name) |