analyze: comment bare literal arguments

docs/CODING_STYLE.md asks for a /* name= */ comment whenever NULL or
another value meaning "unset" is passed to a function. Add it wherever
a bare NULL, 0, false or true is passed for a parameter with a telling
name. Mechanical, generated by tools/check-argument-comments.py --fix.
This commit is contained in:
Christian Brauner committed 2026-10-30 13:37:01 +01:00
1 parent 09b382c01e
commit 7fcedbcdd6
28 files changed
+72 -72

No files matched your search

+4 -4
View File
@@ -16,7 +16,7 @@ int verb_blame(int argc, char *argv[], uintptr_t _data, void *userdata) {
TableCell *cell;
int n, r;
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
@@ -28,19 +28,19 @@ int verb_blame(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
assert_se(cell = table_get_cell(table, 0, 0));
assert_se(cell = table_get_cell(table, /* row= */ 0, /* column= */ 0));
(void) table_set_ellipsize_percent(table, cell, 100);
(void) table_set_align_percent(table, cell, 100);
assert_se(cell = table_get_cell(table, 0, 1));
assert_se(cell = table_get_cell(table, /* row= */ 0, 1));
(void) table_set_ellipsize_percent(table, cell, 100);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);
r = table_set_reverse(table, 0, true);
r = table_set_reverse(table, /* column= */ 0, true);
if (r < 0)
return table_log_sort_error(r);
+3 -3
View File
@@ -34,10 +34,10 @@ static int test_calendar_one(usec_t n, const char *p) {
if (!table)
return log_oom();
assert_se(cell = table_get_cell(table, 0, 0));
assert_se(cell = table_get_cell(table, /* row= */ 0, /* column= */ 0));
(void) table_set_ellipsize_percent(table, cell, 100);
assert_se(cell = table_get_cell(table, 0, 1));
assert_se(cell = table_get_cell(table, /* row= */ 0, 1));
(void) table_set_ellipsize_percent(table, cell, 100);
if (!streq(t, p)) {
@@ -87,7 +87,7 @@ static int test_calendar_one(usec_t n, const char *p) {
else
k = 0;
r = table_add_cell_stringf_full(table, NULL, TABLE_FIELD, "Iteration #%u", i+1);
r = table_add_cell_stringf_full(table, /* ret_cell= */ NULL, TABLE_FIELD, "Iteration #%u", i+1);
if (r < 0)
return table_log_add_error(r);
+1 -1
View File
@@ -28,7 +28,7 @@ int verb_capabilities(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
(void) table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
(void) table_set_align_percent(table, table_get_cell(table, /* row= */ 0, 1), 100);
/* Determine the maximum of the last cap known by the kernel and by us */
last_cap = MAX((unsigned) CAP_LAST_CAP, cap_last_cap());
+3 -3
View File
@@ -297,7 +297,7 @@ static int edid_search(char16_t **ret_panel) {
if (r < 0)
return log_error_errno(r, "Failed to allow uninitialized device enumerator: %m");
r = sd_device_enumerator_add_match_subsystem(e, "drm", true);
r = sd_device_enumerator_add_match_subsystem(e, "drm", /* match= */ true);
if (r < 0)
return log_error_errno(r, "Failed to add drm match subsystem to device enumerator: %m");
@@ -350,8 +350,8 @@ int verb_chid(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
(void) table_set_align_percent(table, table_get_cell(table, 0, 0), 100);
(void) table_set_align_percent(table, table_get_cell(table, 0, 1), 50);
(void) table_set_align_percent(table, table_get_cell(table, /* row= */ 0, /* column= */ 0), 100);
(void) table_set_align_percent(table, table_get_cell(table, /* row= */ 0, 1), 50);
_cleanup_(smbios_fields_free) char16_t* smbios_fields[_CHID_SMBIOS_FIELDS_MAX] = {};
r = smbios_fields_acquire(smbios_fields);
+3 -3
View File
@@ -140,7 +140,7 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned level,
if (strv_contains(*units, *c)) {
r = list_dependencies_print("...", level + 1, (branches << 1) | (to_print ? 1 : 0),
true, NULL, boot);
/* last= */ true, /* times= */ NULL, boot);
if (r < 0)
return r;
continue;
@@ -206,7 +206,7 @@ static int list_dependencies(sd_bus *bus, const char *name) {
printf("%s\n", id);
}
return list_dependencies_one(bus, name, 0, &units, 0);
return list_dependencies_one(bus, name, /* level= */ 0, &units, /* branches= */ 0);
}
int verb_critical_chain(int argc, char *argv[], uintptr_t _data, void *userdata) {
@@ -214,7 +214,7 @@ int verb_critical_chain(int argc, char *argv[], uintptr_t _data, void *userdata)
_cleanup_(unit_times_free_arrayp) UnitTimes *times = NULL;
int n, r;
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+2 -2
View File
@@ -28,7 +28,7 @@ int verb_dlopen_metadata(int argc, char *argv[], uintptr_t _data, void *userdata
arg_root,
/* fork_disable_dump= */ false,
/* ret= */ NULL,
NULL,
/* ret_package_metadata= */ NULL,
&dlopen_metadata);
if (r < 0)
return log_error_errno(r, "Parsing \"%s\" as ELF object failed: %m", abspath);
@@ -37,7 +37,7 @@ int verb_dlopen_metadata(int argc, char *argv[], uintptr_t _data, void *userdata
return log_error_errno(SYNTHETIC_ERRNO(ENODATA), "%s does not contain any .note.dlopen sections", argv[1]);
if (sd_json_format_enabled(arg_json_format_flags))
return sd_json_variant_dump(dlopen_metadata, arg_json_format_flags, stdout, NULL);
return sd_json_variant_dump(dlopen_metadata, arg_json_format_flags, stdout, /* prefix= */ NULL);
_cleanup_(table_unrefp) Table *t = NULL;
t = table_new("feature", "description", "soname", "priority");
+2 -2
View File
@@ -156,7 +156,7 @@ int verb_dot(int argc, char *argv[], uintptr_t _data, void *userdata) {
UnitInfo u;
int r;
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
@@ -172,7 +172,7 @@ int verb_dot(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (r < 0)
return r;
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, NULL);
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, /* types= */ NULL);
if (r < 0)
return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r));
+6 -6
View File
@@ -20,7 +20,7 @@ static int dump_string(sd_bus *bus) {
assert(bus);
r = bus_call_method(bus, bus_systemd_mgr, "Dump", &error, &reply, NULL);
r = bus_call_method(bus, bus_systemd_mgr, "Dump", &error, &reply, /* types= */ NULL);
if (r < 0)
return log_error_errno(r, "Failed to call Dump: %s", bus_error_message(&error, r));
@@ -32,7 +32,7 @@ static int dump_fd(sd_bus *bus) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
r = bus_call_method(bus, bus_systemd_mgr, "DumpByFileDescriptor", &error, &reply, NULL);
r = bus_call_method(bus, bus_systemd_mgr, "DumpByFileDescriptor", &error, &reply, /* types= */ NULL);
if (IN_SET(r, -EACCES, -EBADR))
/* Fall back to non-fd method. We need to do this even if the bus supports sending
* fds to cater to very old managers which didn't have the fd-based method. */
@@ -60,7 +60,7 @@ static int dump_patterns_string(sd_bus *bus, char **patterns) {
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_call(bus, m, 0, &error, &reply);
r = sd_bus_call(bus, m, /* usec= */ 0, &error, &reply);
if (r < 0)
return log_error_errno(r, "Failed to call DumpUnitsMatchingPatterns: %s",
bus_error_message(&error, r));
@@ -84,7 +84,7 @@ static int dump_patterns_fd(sd_bus *bus, char **patterns) {
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_call(bus, m, 0, &error, &reply);
r = sd_bus_call(bus, m, /* usec= */ 0, &error, &reply);
if (r < 0)
return log_error_errno(r, "Failed to call DumpUnitsMatchingPatternsByFileDescriptor: %s",
bus_error_message(&error, r));
@@ -101,7 +101,7 @@ static int mangle_patterns(char **args, char ***ret) {
STRV_FOREACH(arg, args) {
char *t;
r = unit_name_mangle_with_suffix(*arg, NULL, UNIT_NAME_MANGLE_GLOB, ".service", &t);
r = unit_name_mangle_with_suffix(*arg, /* operation= */ NULL, UNIT_NAME_MANGLE_GLOB, ".service", &t);
if (r < 0)
return log_error_errno(r, "Failed to mangle name '%s': %m", *arg);
@@ -119,7 +119,7 @@ int verb_dump(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_strv_free_ char **patterns = NULL;
int r;
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+1 -1
View File
@@ -15,7 +15,7 @@ int verb_exit_status(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
r = table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
r = table_set_align_percent(table, table_get_cell(table, /* row= */ 0, 1), 100);
if (r < 0)
return log_error_errno(r, "Failed to right-align status: %m");
+2 -2
View File
@@ -26,7 +26,7 @@ static int dump_fdstore(sd_bus *bus, const char *arg) {
assert(bus);
assert(arg);
r = unit_name_mangle_with_suffix(arg, NULL, UNIT_NAME_MANGLE_GLOB, ".service", &unit);
r = unit_name_mangle_with_suffix(arg, /* operation= */ NULL, UNIT_NAME_MANGLE_GLOB, ".service", &unit);
if (r < 0)
return log_error_errno(r, "Failed to mangle name '%s': %m", arg);
@@ -105,7 +105,7 @@ int verb_fdstore(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+1 -1
View File
@@ -116,7 +116,7 @@ static int analyze_elf(char **filenames, sd_json_format_flags_t json_flags) {
}
if (sd_json_format_enabled(json_flags))
sd_json_variant_dump(package_metadata, json_flags, stdout, NULL);
sd_json_variant_dump(package_metadata, json_flags, stdout, /* prefix= */ NULL);
else {
r = table_print_or_warn(t);
if (r < 0)
+1 -1
View File
@@ -14,7 +14,7 @@ int verb_log_control(int argc, char *argv[], uintptr_t _data, void *userdata) {
assert(IN_SET(argc, 1, 2));
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+2 -2
View File
@@ -27,7 +27,7 @@ static int dump_malloc_info(sd_bus *bus, char *service) {
"GetMallocInfo",
&error,
&reply,
NULL);
/* types= */ NULL);
if (r < 0)
return log_error_errno(r, "Failed to call GetMallocInfo on '%s': %s", service, bus_error_message(&error, r));
@@ -47,7 +47,7 @@ int verb_malloc(int argc, char *argv[], uintptr_t _data, void *userdata) {
services = args;
}
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+2 -2
View File
@@ -67,8 +67,8 @@ int verb_nvpcrs(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
(void) table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
(void) table_set_align_percent(table, table_get_cell(table, 0, 2), 100);
(void) table_set_align_percent(table, table_get_cell(table, /* row= */ 0, 1), 100);
(void) table_set_align_percent(table, table_get_cell(table, /* row= */ 0, 2), 100);
table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
(void) table_set_sort(table, (size_t) 2, (size_t) 0);
+2 -2
View File
@@ -80,7 +80,7 @@ static int add_pcr_to_table(Table *table, const char *alg, uint32_t pcr) {
return log_oom();
/* Grey out PCRs that are not sensibly initialized */
if (memeqbyte(0, buf, bufsize) ||
if (memeqbyte(/* byte= */ 0, buf, bufsize) ||
memeqbyte(0xFFU, buf, bufsize))
color = ansi_grey();
}
@@ -113,7 +113,7 @@ int verb_pcrs(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
(void) table_set_align_percent(table, table_get_cell(table, 0, 0), 100);
(void) table_set_align_percent(table, table_get_cell(table, /* row= */ 0, /* column= */ 0), 100);
table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
if (!alg) /* hide hash column if we couldn't acquire it */
+4 -4
View File
@@ -108,7 +108,7 @@ static int acquire_host_info(sd_bus *bus, HostInfo **hi) {
hostname_map,
BUS_MAP_STRDUP,
&error,
NULL,
/* ret_reply= */ NULL,
host);
if (r < 0) {
log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s",
@@ -124,7 +124,7 @@ manager:
manager_map,
BUS_MAP_STRDUP,
&error,
NULL,
/* ret_reply= */ NULL,
host);
if (r < 0)
return log_error_errno(r, "Failed to get host information from systemd: %s",
@@ -320,7 +320,7 @@ static int produce_plot_as_svg(
svg("<text x=\"20\" y=\"50\">%s</text>", pretty_times);
if (host)
svg("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>",
os_release_pretty_name(host->os_pretty_name, NULL),
os_release_pretty_name(host->os_pretty_name, /* name= */ NULL),
strempty(host->hostname),
strempty(host->kernel_name),
strempty(host->kernel_release),
@@ -330,7 +330,7 @@ static int produce_plot_as_svg(
svg("<g transform=\"translate(%.3f,100)\">\n", 20.0 + (SCALE_X * boot->firmware_time));
if (boot->soft_reboots_count > 0)
svg_graph_box(m, 0, boot->finish_time);
svg_graph_box(m, /* begin= */ 0, boot->finish_time);
else
svg_graph_box(m, -(double) boot->firmware_time, boot->finish_time);
+6 -6
View File
@@ -1775,7 +1775,7 @@ static int assess(const SecurityInfo *info,
if (!details_table)
return log_oom();
r = table_set_json_field_name(details_table, 0, "set");
r = table_set_json_field_name(details_table, /* idx= */ 0, "set");
if (r < 0)
return log_error_errno(r, "Failed to set JSON field name of column 0: %m");
@@ -2387,7 +2387,7 @@ static int acquire_security_info(sd_bus *bus, const char *name, SecurityInfo *in
security_map,
BUS_MAP_STRDUP | BUS_MAP_BOOLEAN_AS_BOOL,
&error,
NULL,
/* ret_reply= */ NULL,
info);
if (r < 0)
return log_error_errno(r, "Failed to get unit properties: %s", bus_error_message(&error, r));
@@ -2787,7 +2787,7 @@ static int offline_security_checks(
profile = profile_path;
}
r = copy_file(profile, dropin, 0, 0644, 0);
r = copy_file(profile, dropin, /* open_flags= */ 0, 0644, /* copy_flags= */ 0);
if (r < 0)
return log_error_errno(r, "Failed to copy: %m");
}
@@ -2847,7 +2847,7 @@ static int analyze_security(sd_bus *bus,
"ListUnits",
&error,
&reply,
NULL);
/* types= */ NULL);
if (r < 0)
return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r));
@@ -2897,7 +2897,7 @@ static int analyze_security(sd_bus *bus,
fflush(stdout);
}
r = unit_name_mangle(*i, 0, &mangled);
r = unit_name_mangle(*i, /* flags= */ 0, &mangled);
if (r < 0)
return log_error_errno(r, "Failed to mangle unit name '%s': %m", *i);
@@ -2939,7 +2939,7 @@ int verb_security(int argc, char *argv[], uintptr_t _data, void *userdata) {
int r;
if (!arg_offline) {
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
}
+1 -1
View File
@@ -19,7 +19,7 @@ int verb_service_watchdogs(int argc, char *argv[], uintptr_t _data, void *userda
assert(IN_SET(argc, 1, 2));
assert(argv);
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+3 -3
View File
@@ -85,7 +85,7 @@ int acquire_boot_times(sd_bus *bus, bool require_finished, BootTimes **ret) {
property_map,
BUS_MAP_STRDUP,
&error,
NULL,
/* ret_reply= */ NULL,
&times);
if (r < 0)
return log_error_errno(r, "Failed to get timestamp properties: %s", bus_error_message(&error, r));
@@ -330,7 +330,7 @@ int acquire_time_data(sd_bus *bus, bool require_finished, UnitTimes **out) {
if (r < 0)
return r;
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, NULL);
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, /* types= */ NULL);
if (r < 0)
return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r));
@@ -357,7 +357,7 @@ int acquire_time_data(sd_bus *bus, bool require_finished, UnitTimes **out) {
property_map,
BUS_MAP_STRDUP,
&error,
NULL,
/* ret_reply= */ NULL,
t);
if (r < 0)
return log_error_errno(r, "Failed to get timestamp properties of unit %s: %s",
+1 -1
View File
@@ -14,7 +14,7 @@ int verb_time(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_free_ char *buf = NULL;
int r;
r = acquire_bus(&bus, NULL);
r = acquire_bus(&bus, /* use_full_bus= */ NULL);
if (r < 0)
return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+3 -3
View File
@@ -27,10 +27,10 @@ int verb_timespan(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (!table)
return log_oom();
assert_se(cell = table_get_cell(table, 0, 0));
assert_se(cell = table_get_cell(table, /* row= */ 0, /* column= */ 0));
(void) table_set_ellipsize_percent(table, cell, 100);
assert_se(cell = table_get_cell(table, 0, 1));
assert_se(cell = table_get_cell(table, /* row= */ 0, 1));
(void) table_set_ellipsize_percent(table, cell, 100);
r = table_add_many(table,
@@ -39,7 +39,7 @@ int verb_timespan(int argc, char *argv[], uintptr_t _data, void *userdata) {
if (r < 0)
return table_log_add_error(r);
r = table_add_cell_stringf_full(table, NULL, TABLE_FIELD, "%ss", glyph(GLYPH_MU));
r = table_add_cell_stringf_full(table, /* ret_cell= */ NULL, TABLE_FIELD, "%ss", glyph(GLYPH_MU));
if (r < 0)
return table_log_add_error(r);
+3 -3
View File
@@ -26,10 +26,10 @@ static int test_timestamp_one(const char *p) {
if (!table)
return log_oom();
assert_se(cell = table_get_cell(table, 0, 0));
assert_se(cell = table_get_cell(table, /* row= */ 0, /* column= */ 0));
(void) table_set_ellipsize_percent(table, cell, 100);
assert_se(cell = table_get_cell(table, 0, 1));
assert_se(cell = table_get_cell(table, /* row= */ 0, 1));
(void) table_set_ellipsize_percent(table, cell, 100);
r = table_add_many(table,
@@ -49,7 +49,7 @@ static int test_timestamp_one(const char *p) {
return table_log_add_error(r);
}
r = table_add_cell(table, NULL, TABLE_FIELD, "UNIX seconds");
r = table_add_cell(table, /* ret_cell= */ NULL, TABLE_FIELD, "UNIX seconds");
if (r < 0)
return table_log_add_error(r);
+2 -2
View File
@@ -29,11 +29,11 @@ int verb_unit_files(int argc, char *argv[], uintptr_t _data, void *userdata) {
char **v;
int r;
r = lookup_paths_init_or_warn(&lp, arg_runtime_scope, 0, NULL);
r = lookup_paths_init_or_warn(&lp, arg_runtime_scope, /* flags= */ 0, /* root_dir= */ NULL);
if (r < 0)
return r;
r = unit_file_build_name_map(&lp, NULL, &unit_ids, &unit_names, NULL);
r = unit_file_build_name_map(&lp, /* cache_timestamp_hash= */ NULL, &unit_ids, &unit_names, /* path_cache= */ NULL);
if (r < 0)
return log_error_errno(r, "unit_file_build_name_map() failed: %m");
+1 -1
View File
@@ -11,7 +11,7 @@ int verb_unit_paths(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(lookup_paths_done) LookupPaths paths = {};
int r;
r = lookup_paths_init_or_warn(&paths, arg_runtime_scope, 0, NULL);
r = lookup_paths_init_or_warn(&paths, arg_runtime_scope, /* flags= */ 0, /* root_dir= */ NULL);
if (r < 0)
return r;
+2 -2
View File
@@ -198,7 +198,7 @@ int verify_executable(Unit *u, const ExecCommand *exec, const char *root) {
if (exec->flags & EXEC_COMMAND_IGNORE_FAILURE)
return 0;
r = find_executable_full(exec->path, root, NULL, false, NULL, NULL);
r = find_executable_full(exec->path, root, /* exec_search_path= */ NULL, /* use_path_envvar= */ false, /* ret_filename= */ NULL, /* ret_fd= */ NULL);
if (r < 0)
return log_unit_error_errno(u, r, "Command %s is not executable: %m", exec->path);
@@ -230,7 +230,7 @@ static int verify_documentation(Unit *u, bool check_man) {
log_unit_debug(u, "Found documentation item: %s", *p);
if (check_man && startswith(*p, "man:")) {
k = show_man_page(*p + 4, true);
k = show_man_page(*p + 4, /* null_stdio= */ true);
if (k != 0) {
if (k < 0) {
const char *hint = "";
+1 -1
View File
@@ -46,7 +46,7 @@ static int process_aliases(char *argv[], char *tempdir, char ***ret) {
if (!dst)
return -ENOMEM;
r = copy_file(src, dst, 0, 0644, /* copy_flags= */ 0);
r = copy_file(src, dst, /* open_flags= */ 0, 0644, /* copy_flags= */ 0);
if (r < 0)
return r;
+3 -3
View File
@@ -163,13 +163,13 @@ int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char *proper
}
void time_parsing_hint(const char *p, bool calendar, bool timestamp, bool timespan) {
if (calendar && calendar_spec_from_string(p, NULL) >= 0)
if (calendar && calendar_spec_from_string(p, /* ret= */ NULL) >= 0)
log_notice("Hint: this expression is a valid calendar specification. "
"Use 'systemd-analyze calendar \"%s\"' instead?", p);
if (timestamp && parse_timestamp(p, NULL) >= 0)
if (timestamp && parse_timestamp(p, /* ret= */ NULL) >= 0)
log_notice("Hint: this expression is a valid timestamp. "
"Use 'systemd-analyze timestamp \"%s\"' instead?", p);
if (timespan && parse_time(p, NULL, USEC_PER_SEC) >= 0)
if (timespan && parse_time(p, /* ret= */ NULL, USEC_PER_SEC) >= 0)
log_notice("Hint: this expression is a valid timespan. "
"Use 'systemd-analyze timespan \"%s\"' instead?", p);
}
+7 -7
View File
@@ -16,12 +16,12 @@ const char *arg_instance = "test_instance";
TEST(verify_nonexistent) {
/* Negative cases */
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/non/existent"}, NULL) == 0);
assert_se(verify_executable(NULL, &(ExecCommand) {.path = (char*) "/non/existent"}, NULL) < 0);
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/non/existent"}, /* root= */ NULL) == 0);
assert_se(verify_executable(NULL, &(ExecCommand) {.path = (char*) "/non/existent"}, /* root= */ NULL) < 0);
/* Ordinary cases */
assert_se(verify_executable(NULL, &(ExecCommand) {.path = (char*) "/bin/echo"}, NULL) == 0);
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/bin/echo"}, NULL) == 0);
assert_se(verify_executable(NULL, &(ExecCommand) {.path = (char*) "/bin/echo"}, /* root= */ NULL) == 0);
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/bin/echo"}, /* root= */ NULL) == 0);
}
static void test_verify_set_unit_path_one(const char *old, const char *expected) {
@@ -52,12 +52,12 @@ TEST(verify_set_unit_path) {
_cleanup_free_ char *old_saved = getenv("SYSTEMD_UNIT_PATH") ? strdup(getenv("SYSTEMD_UNIT_PATH")) : NULL;
ASSERT_TRUE(old_saved || !getenv("SYSTEMD_UNIT_PATH"));
test_verify_set_unit_path_one(NULL, ":");
test_verify_set_unit_path_one(/* old= */ NULL, ":");
test_verify_set_unit_path_one("", "");
test_verify_set_unit_path_one(":", ":");
test_verify_set_unit_path_one("/foo:", ":/foo:");
test_verify_set_unit_path_one(":foo", NULL);
test_verify_set_unit_path_one("/foo::/bar", NULL);
test_verify_set_unit_path_one(":foo", /* expected= */ NULL);
test_verify_set_unit_path_one("/foo::/bar", /* expected= */ NULL);
if (old_saved)
ASSERT_OK_ERRNO(setenv("SYSTEMD_UNIT_PATH", old_saved, 1));