From: Zbigniew Jędrzejewski-Szmek Date: Tue, 19 Nov 2024 15:51:27 +0000 (+0100) Subject: various: handle the positive condition after strv_skip() first X-Git-Tag: v258-rc1~987^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdfa9fd8abbc0e07738b1345ea1b15350ef158d2;p=thirdparty%2Fsystemd.git various: handle the positive condition after strv_skip() first --- diff --git a/src/id128/id128.c b/src/id128/id128.c index ed444c8022e..d3e2f28c1e0 100644 --- a/src/id128/id128.c +++ b/src/id128/id128.c @@ -133,17 +133,7 @@ static int verb_show(int argc, char **argv, void *userdata) { int r; argv = strv_skip(argv, 1); - if (strv_isempty(argv)) { - if (!sd_id128_is_null(arg_app)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "'show --app-specific=' can only be used with explicit UUID input."); - - for (const GptPartitionType *e = gpt_partition_type_table; e->name; e++) { - r = show_one(&table, e->name, e->uuid, e == gpt_partition_type_table); - if (r < 0) - return r; - } - } else + if (argv) STRV_FOREACH(p, argv) { sd_id128_t uuid; const char *id = NULL; @@ -171,6 +161,17 @@ static int verb_show(int argc, char **argv, void *userdata) { if (r < 0) return r; } + else { + if (!sd_id128_is_null(arg_app)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "'show --app-specific=' can only be used with explicit UUID input."); + + for (const GptPartitionType *e = gpt_partition_type_table; e->name; e++) { + r = show_one(&table, e->name, e->uuid, e == gpt_partition_type_table); + if (r < 0) + return r; + } + } if (table) { r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c index 335e32f71c4..8cd9fc83a1a 100644 --- a/src/systemctl/systemctl-list-dependencies.c +++ b/src/systemctl/systemctl-list-dependencies.c @@ -171,14 +171,14 @@ int verb_list_dependencies(int argc, char *argv[], void *userdata) { return r; patterns = strv_skip(argv, 1); - if (strv_isempty(patterns)) { - units = strv_new(SPECIAL_DEFAULT_TARGET); - if (!units) - return log_oom(); - } else { + if (patterns) { r = expand_unit_names(bus, patterns, NULL, &units, NULL); if (r < 0) return log_error_errno(r, "Failed to expand names: %m"); + } else { + units = strv_new(SPECIAL_DEFAULT_TARGET); + if (!units) + return log_oom(); } pager_open(arg_pager_flags); diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index e0553ce3e4b..33031f7f402 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -35,7 +35,10 @@ static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) { "%s: expected: load [module…]", argv[0]); char **modules = strv_skip(argv, 2); - if (strv_isempty(modules)) { + if (modules) + STRV_FOREACH(module, modules) + (void) module_load_and_warn(ctx, *module, /* verbose = */ false); + else { const char *modalias; r = sd_device_get_property_value(dev, "MODALIAS", &modalias); @@ -43,9 +46,7 @@ static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) { return log_device_warning_errno(dev, r, "Failed to read property \"MODALIAS\": %m"); (void) module_load_and_warn(ctx, modalias, /* verbose = */ false); - } else - STRV_FOREACH(module, modules) - (void) module_load_and_warn(ctx, *module, /* verbose = */ false); + } return 0; }