shared: 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.

While at it, add the '=' that some of the existing comments are missing.

By hand, drop the /* uncompressed */ in dns_packet_read_rr() which only
repeats the new comment, and wrap the get_mempolicy() call in
numa-util.c that grew to 141 columns.
This commit is contained in:
Christian Brauner committed 2026-11-04 23:20:15 +01:00
1 parent 60cc1cc33c
commit fae98e8341
10 files changed
+28 -27

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ static inline int compat_bpf_map_create(
value_size, max_entries, opts);
return sym_bpf_create_map(map_type, key_size, value_size, max_entries,
0 /* opts->map_flags, but opts is always NULL for us so skip build dependency on the type */);
/* map_flags= */ 0 /* opts->map_flags, but opts is always NULL for us so skip build dependency on the type */);
}
/* libbpf sometimes returns error codes that make sense only in the kernel, like 524 for EOPNOTSUPP. Use
+1 -1
View File
@@ -246,7 +246,7 @@ static void bus_wait_for_units_check_ready(BusWaitForUnits *d) {
d->state = d->has_failed ? BUS_WAIT_FAILURE : BUS_WAIT_SUCCESS;
if (d->event)
(void) sd_event_exit(d->event, 0);
(void) sd_event_exit(d->event, /* code= */ 0);
}
static void wait_for_item_fail(WaitForItem *item) {
+1 -1
View File
@@ -85,7 +85,7 @@ int copy_data_fd_full(int fd, uint64_t max_size) {
/* If we have reason to believe this will fit fine in /tmp, then use that as first fallback. */
if ((!S_ISREG(st.st_mode) || (uint64_t) st.st_size < DATA_FD_TMP_LIMIT)) {
tmp_fd = open_tmpfile_unlinkable(NULL /* NULL as directory means /tmp */, O_RDWR);
tmp_fd = open_tmpfile_unlinkable(/* directory= */ NULL /* NULL as directory means /tmp */, O_RDWR);
if (tmp_fd < 0)
return tmp_fd;
+1 -1
View File
@@ -2399,7 +2399,7 @@ int dns_packet_read_rr(
if (r < 0)
return r;
r = dns_packet_read_name(p, &rr->svcb.target_name, false /* uncompressed */, /* start= */ NULL);
r = dns_packet_read_name(p, &rr->svcb.target_name, /* allow_compression= */ false, /* start= */ NULL);
if (r < 0)
return r;
+1 -1
View File
@@ -799,7 +799,7 @@ int config_parse_image_policy(
return 0;
}
r = image_policy_from_string(rvalue, /* graceful */ true, &np);
r = image_policy_from_string(rvalue, /* graceful= */ true, &np);
if (r == -ENOTUNIQ)
return log_syntax(unit, LOG_ERR, filename, line, r, "Duplicate rule in image policy, refusing: %s", rvalue);
if (r == -EBADSLT)
+11 -11
View File
@@ -2021,14 +2021,14 @@ int fsmount_credentials_fs(int *ret_fsfd) {
if (fs_fd < 0)
return -errno;
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "nr_inodes", "1024", 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "nr_inodes", "1024", /* aux= */ 0) < 0)
return -errno;
xsprintf(size_str, "%" PRIu64, CREDENTIALS_TOTAL_SIZE_MAX);
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "size", size_str, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "size", size_str, /* aux= */ 0) < 0)
return -errno;
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "noswap", NULL, 0) < 0) {
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "noswap", /* value= */ NULL, /* aux= */ 0) < 0) {
if (errno != EINVAL)
return -errno;
@@ -2037,10 +2037,10 @@ int fsmount_credentials_fs(int *ret_fsfd) {
close_and_replace(fs_fd, ramfs_fd);
}
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "mode", "0700", 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "mode", "0700", /* aux= */ 0) < 0)
return -errno;
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
return -errno;
unsigned mount_attrs = ms_flags_to_mount_attr(credentials_fs_mount_flags(/* ro = */ false));
@@ -2109,11 +2109,11 @@ int make_fsmount(
if (fs_fd < 0)
return log_full_errno(error_log_level, errno, "Failed to open superblock for \"%s\": %m", type);
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "source", what, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, "source", what, /* aux= */ 0) < 0)
return log_full_errno(error_log_level, errno, "Failed to set mount source for \"%s\" to \"%s\": %m", type, what);
if (FLAGS_SET(f, MS_RDONLY))
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, "ro", /* value= */ NULL, /* aux= */ 0) < 0)
return log_full_errno(error_log_level, errno, "Failed to set read only mount flag for \"%s\": %m", type);
for (const char *p = o;;) {
@@ -2131,18 +2131,18 @@ int make_fsmount(
*eq = 0;
eq++;
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, word, eq, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_STRING, word, eq, /* aux= */ 0) < 0)
return log_full_errno(error_log_level, errno, "Failed to set mount option \"%s=%s\" for \"%s\": %m", word, eq, type);
} else {
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, word, NULL, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_SET_FLAG, word, /* value= */ NULL, /* aux= */ 0) < 0)
return log_full_errno(error_log_level, errno, "Failed to set mount flag \"%s\" for \"%s\": %m", word, type);
}
}
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
return log_full_errno(error_log_level, errno, "Failed to realize fs fd for \"%s\" (\"%s\"): %m", what, type);
mnt_fd = fsmount(fs_fd, FSMOUNT_CLOEXEC, 0);
mnt_fd = fsmount(fs_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
if (mnt_fd < 0)
return log_full_errno(error_log_level, errno, "Failed to create mount fd for \"%s\" (\"%s\"): %m", what, type);
+5 -5
View File
@@ -904,7 +904,7 @@ static int mstack_make_overlayfs(
report_errno_and_exit(errno_pipe_fds[1], /* error= */ 0);
}
_cleanup_close_ int overlayfs_mnt_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, 0);
_cleanup_close_ int overlayfs_mnt_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
if (overlayfs_mnt_fd < 0)
return log_debug_errno(errno, "Failed to create mount fd: %m");
@@ -951,16 +951,16 @@ int mstack_make_mounts(
if (sb_fd < 0)
return log_debug_errno(errno, "Failed to create tmpfs: %m");
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "source", mstack->path, 0) < 0)
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "source", mstack->path, /* aux= */ 0) < 0)
return log_debug_errno(errno, "Failed to set mount source: %m");
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "mode", "0755", 0) < 0)
if (fsconfig(sb_fd, FSCONFIG_SET_STRING, "mode", "0755", /* aux= */ 0) < 0)
return log_debug_errno(errno, "Failed to set mount source: %m");
if (fsconfig(sb_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0)
if (fsconfig(sb_fd, FSCONFIG_CMD_CREATE, /* key= */ NULL, /* value= */ NULL, /* aux= */ 0) < 0)
return log_debug_errno(errno, "Failed to realize tmpfs: %m");
mstack->root_mount_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, 0);
mstack->root_mount_fd = fsmount(sb_fd, FSMOUNT_CLOEXEC, /* attr_flags= */ 0);
if (mstack->root_mount_fd < 0)
return log_debug_errno(errno, "Failed to create mount fd: %m");
+2 -1
View File
@@ -72,7 +72,8 @@ int apply_numa_policy(const NUMAPolicy *policy) {
assert(policy);
if (get_mempolicy(NULL, NULL, 0, NULL, 0) < 0 && errno == ENOSYS)
if (get_mempolicy(/* mode= */ NULL, /* nodemask= */ NULL, /* maxnode= */ 0,
/* addr= */ NULL, /* flags= */ 0) < 0 && errno == ENOSYS)
/* NUMA syscall interface not available (kernel compiled without NUMA support).
* Return -ENOSYS so callers can distinguish this from -EOPNOTSUPP, which we
* return below when the syscall interface exists but the requested policy is
+2 -2
View File
@@ -2228,7 +2228,7 @@ static int add_personality_rules(scmp_filter_ctx seccomp, uint32_t arch, uint32_
assert((value & ~mask) == 0);
BIT_FOREACH(bit, value) {
r = add_personality_rule(seccomp, arch, INDEX_TO_MASK(uint32_t, bit), 0);
r = add_personality_rule(seccomp, arch, INDEX_TO_MASK(uint32_t, bit), /* value= */ 0);
if (r < 0)
return r;
}
@@ -2281,7 +2281,7 @@ int seccomp_restrict_read_implies_exec(void) {
if (r < 0)
return r;
r = add_personality_rules(seccomp, arch, READ_IMPLIES_EXEC, 0);
r = add_personality_rules(seccomp, arch, READ_IMPLIES_EXEC, /* value= */ 0);
if (r < 0)
return r;
+3 -3
View File
@@ -115,7 +115,7 @@ bool uapi16_name_is_valid(const char *s) {
if (!path_is_normalized(s))
return false;
if (string_has_cc(s, NULL))
if (string_has_cc(s, /* ok= */ NULL))
return false;
if (uapi16_manifest_filename_is_reserved(s))
@@ -130,7 +130,7 @@ bool uapi16_xattr_name_is_valid(const char *s) {
return !isempty(s) &&
utf8_is_valid(s) &&
!string_has_cc(s, NULL);
!string_has_cc(s, /* ok= */ NULL);
}
static int json_dispatch_uapi16_name(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
@@ -426,7 +426,7 @@ int uapi16_xattrs_build_json(const Uapi16Xattr *x, size_t n, sd_json_variant **r
assert(ret);
_cleanup_(sd_json_variant_unrefp) sd_json_variant *ns = NULL;
r = sd_json_variant_new_object(&ns, NULL, 0);
r = sd_json_variant_new_object(&ns, /* array= */ NULL, 0);
if (r < 0)
return r;