tree-wide: normalize comment style

This commit is contained in:
Yu Watanabe
2025-12-15 08:50:13 +09:00
parent 8e20b9a79d
commit 93378148d4
431 changed files with 1894 additions and 1895 deletions
+4 -4
View File
@@ -264,7 +264,7 @@ int pin_callout_binary(const char *path, char **ret_path) {
const char *e;
if (find_environment_binary(fn, &e) >= 0) {
/* The environment variable counts. We'd fail if the executable is not available/invalid. */
r = open_and_check_executable(e, /* root = */ NULL, ret_path, &fd);
r = open_and_check_executable(e, /* root= */ NULL, ret_path, &fd);
if (r < 0)
return r;
@@ -273,13 +273,13 @@ int pin_callout_binary(const char *path, char **ret_path) {
_cleanup_free_ char *np = NULL;
if (find_build_dir_binary(fn, &np) >= 0) {
r = open_and_check_executable(np, /* root = */ NULL, ret_path, &fd);
r = open_and_check_executable(np, /* root= */ NULL, ret_path, &fd);
if (r >= 0)
return fd;
}
r = find_executable_full(path, /* root = */ NULL,
/* exec_search_path = */ NULL, /* use_path_envvar = */ true,
r = find_executable_full(path, /* root= */ NULL,
/* exec_search_path= */ NULL, /* use_path_envvar= */ true,
ret_path, &fd);
if (r < 0)
return r;
+8 -8
View File
@@ -241,7 +241,7 @@ int cg_enumerate_subgroups(const char *path, DIR **ret) {
/* This is not recursive! */
r = cg_get_path(path, /* suffix = */ NULL, &fs);
r = cg_get_path(path, /* suffix= */ NULL, &fs);
if (r < 0)
return r;
@@ -479,7 +479,7 @@ int cg_set_xattr(const char *path, const char *name, const void *value, size_t s
assert(name);
assert(value || size <= 0);
r = cg_get_path(path, /* suffix = */ NULL, &fs);
r = cg_get_path(path, /* suffix= */ NULL, &fs);
if (r < 0)
return r;
@@ -493,7 +493,7 @@ int cg_get_xattr(const char *path, const char *name, char **ret, size_t *ret_siz
assert(path);
assert(name);
r = cg_get_path(path, /* suffix = */ NULL, &fs);
r = cg_get_path(path, /* suffix= */ NULL, &fs);
if (r < 0)
return r;
@@ -507,7 +507,7 @@ int cg_get_xattr_bool(const char *path, const char *name) {
assert(path);
assert(name);
r = cg_get_path(path, /* suffix = */ NULL, &fs);
r = cg_get_path(path, /* suffix= */ NULL, &fs);
if (r < 0)
return r;
@@ -521,7 +521,7 @@ int cg_remove_xattr(const char *path, const char *name) {
assert(path);
assert(name);
r = cg_get_path(path, /* suffix = */ NULL, &fs);
r = cg_get_path(path, /* suffix= */ NULL, &fs);
if (r < 0)
return r;
@@ -1193,7 +1193,7 @@ int cg_path_get_slice(const char *p, char **ret_slice) {
const char *s;
int n;
n = path_find_first_component(&p, /* accept_dot_dot = */ false, &s);
n = path_find_first_component(&p, /* accept_dot_dot= */ false, &s);
if (n < 0)
return n;
if (!valid_slice_name(s, n))
@@ -1487,7 +1487,7 @@ int cg_get_owner(const char *path, uid_t *ret_uid) {
assert(ret_uid);
r = cg_get_path(path, /* suffix = */ NULL, &f);
r = cg_get_path(path, /* suffix= */ NULL, &f);
if (r < 0)
return r;
@@ -1525,7 +1525,7 @@ int cg_get_keyed_attribute(
if (r < 0)
return r;
r = read_full_file(filename, &contents, /* ret_size = */ NULL);
r = read_full_file(filename, &contents, /* ret_size= */ NULL);
if (r < 0)
return r;
+1 -1
View File
@@ -403,7 +403,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int
}
/* Otherwise let's pin it by file descriptor, via O_PATH. */
child = r = openat_opath_with_automount(fd, first, /* automount = */ FLAGS_SET(flags, CHASE_TRIGGER_AUTOFS));
child = r = openat_opath_with_automount(fd, first, /* automount= */ FLAGS_SET(flags, CHASE_TRIGGER_AUTOFS));
if (r < 0) {
if (r != -ENOENT)
return r;
+3 -3
View File
@@ -241,9 +241,9 @@ static int set_proj_id_cb(
int set_proj_id_recursive(int fd, uint32_t proj_id) {
return recurse_dir_at(
fd,
/* path = */ NULL,
/* statx_mask = */ 0,
/* n_depth_max = */ UINT_MAX,
/* path= */ NULL,
/* statx_mask= */ 0,
/* n_depth_max= */ UINT_MAX,
RECURSE_DIR_ENSURE_TYPE|RECURSE_DIR_TOPLEVEL|RECURSE_DIR_INODE_FD,
set_proj_id_cb,
UINT32_TO_PTR(proj_id));
+8 -8
View File
@@ -148,7 +148,7 @@ int conf_file_new_at(const char *path, int rfd, ChaseFlags chase_flags, ConfFile
CHASE_AT_RESOLVE_IN_ROOT |
CHASE_MUST_BE_DIRECTORY |
(FLAGS_SET(chase_flags, CHASE_NONEXISTENT) ? CHASE_NONEXISTENT : 0),
&resolved_dirpath, /* ret_fd = */ NULL);
&resolved_dirpath, /* ret_fd= */ NULL);
if (r < 0)
return log_debug_errno(r, "Failed to chase '%s%s': %m", empty_to_root(root), skip_leading_slash(dirpath));
}
@@ -177,7 +177,7 @@ int conf_file_new(const char *path, const char *root, ChaseFlags chase_flags, Co
_cleanup_free_ char *root_abs = NULL;
_cleanup_close_ int rfd = -EBADF;
r = prepare_dirs(root, /* dirs = */ NULL, &rfd, &root_abs, /* ret_dirs = */ NULL);
r = prepare_dirs(root, /* dirs= */ NULL, &rfd, &root_abs, /* ret_dirs= */ NULL);
if (r < 0)
return r;
@@ -593,7 +593,7 @@ int conf_files_list_strv(
return r;
r = conf_files_list_impl(suffix, rfd, root_abs, flags, (const char * const *) dirs_abs,
/* replacement = */ NULL, &fh, /* ret_inserted = */ NULL);
/* replacement= */ NULL, &fh, /* ret_inserted= */ NULL);
if (r < 0)
return r;
@@ -622,7 +622,7 @@ int conf_files_list_strv_full(
return r;
r = conf_files_list_impl(suffix, rfd, root_abs, flags, (const char * const *) dirs_abs,
/* replacement = */ NULL, &fh, /* ret_inserted = */ NULL);
/* replacement= */ NULL, &fh, /* ret_inserted= */ NULL);
if (r < 0)
return r;
@@ -646,11 +646,11 @@ int conf_files_list_strv_at(
if (rfd >= 0 && DEBUG_LOGGING)
(void) fd_get_path(rfd, &root); /* for logging */
r = conf_files_list_impl(suffix, rfd, root, flags, dirs, /* replacement = */ NULL, &fh, /* ret_inserted = */ NULL);
r = conf_files_list_impl(suffix, rfd, root, flags, dirs, /* replacement= */ NULL, &fh, /* ret_inserted= */ NULL);
if (r < 0)
return r;
return copy_and_sort_files_from_hashmap(fh, suffix, /* root = */ NULL, flags, ret);
return copy_and_sort_files_from_hashmap(fh, suffix, /* root= */ NULL, flags, ret);
}
int conf_files_list_strv_at_full(
@@ -672,11 +672,11 @@ int conf_files_list_strv_at_full(
if (rfd >= 0 && DEBUG_LOGGING)
(void) fd_get_path(rfd, &root); /* for logging */
r = conf_files_list_impl(suffix, rfd, root, flags, dirs, /* replacement = */ NULL, &fh, /* ret_inserted = */ NULL);
r = conf_files_list_impl(suffix, rfd, root, flags, dirs, /* replacement= */ NULL, &fh, /* ret_inserted= */ NULL);
if (r < 0)
return r;
return dump_files(fh, /* root = */ NULL, ret_files, ret_n_files);
return dump_files(fh, /* root= */ NULL, ret_files, ret_n_files);
}
int conf_files_list(char ***ret, const char *suffix, const char *root, ConfFilesFlags flags, const char *dir) {
+6 -6
View File
@@ -248,11 +248,11 @@ int efi_set_variable(const char *variable, const void *value, size_t size) {
* accidentally however, hence let's unset the bit first. */
r = chattr_full(AT_FDCWD, p,
/* value = */ 0,
/* mask = */ FS_IMMUTABLE_FL,
/* ret_previous = */ &saved_flags,
/* ret_final = */ NULL,
/* flags = */ 0);
/* value= */ 0,
/* mask= */ FS_IMMUTABLE_FL,
/* ret_previous= */ &saved_flags,
/* ret_final= */ NULL,
/* flags= */ 0);
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to drop FS_IMMUTABLE_FL flag from '%s', ignoring: %m", p);
@@ -288,7 +288,7 @@ int efi_set_variable(const char *variable, const void *value, size_t size) {
/* For some reason efivarfs doesn't update mtime automatically. Let's do it manually then. This is
* useful for processes that cache EFI variables to detect when changes occurred. */
if (futimens(fd, /* times = */ NULL) < 0)
if (futimens(fd, /* times= */ NULL) < 0)
log_debug_errno(errno, "Failed to update mtime/atime on %s, ignoring: %m", p);
r = 0;
+1 -1
View File
@@ -881,7 +881,7 @@ int script_get_shebang_interpreter(const char *path, char **ret) {
_cleanup_free_ char *p = NULL;
const char *s = line;
r = extract_first_word(&s, &p, /* separators = */ NULL, /* flags = */ 0);
r = extract_first_word(&s, &p, /* separators= */ NULL, /* flags= */ 0);
if (r < 0)
return r;
if (r == 0)
+2 -2
View File
@@ -329,7 +329,7 @@ int futimens_opath(int fd, const struct timespec ts[2]) {
/* Support for AT_EMPTY_PATH is added rather late (kernel 5.8), so fall back to going through /proc/
* if unavailable. */
if (utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), ts, /* flags = */ 0) < 0) {
if (utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), ts, /* flags= */ 0) < 0) {
if (errno != ENOENT)
return -errno;
@@ -649,7 +649,7 @@ static int tmp_dir_internal(const char *def, const char **ret) {
return 0;
}
k = is_dir(def, /* follow = */ true);
k = is_dir(def, /* follow= */ true);
if (k == 0)
k = -ENOTDIR;
if (k < 0)
+1 -1
View File
@@ -158,7 +158,7 @@ int glob_extend(char ***strv, const char *path, int flags) {
if (r < 0)
return r;
return strv_extend_strv_consume(strv, v, /* filter_duplicates = */ false);
return strv_extend_strv_consume(strv, v, /* filter_duplicates= */ false);
}
int glob_non_glob_prefix(const char *path, char **ret) {
+5 -5
View File
@@ -44,7 +44,7 @@ int make_lock_file_at(int dir_fd, const char *p, int operation, LockFile *ret) {
fd = xopenat_lock_full(dfd,
p,
O_CREAT|O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NOCTTY,
/* xopen_flags = */ 0,
/* xopen_flags= */ 0,
0600,
LOCK_UNPOSIX,
operation);
@@ -154,11 +154,11 @@ static int fcntl_lock(int fd, int operation, bool ofd) {
}
int posix_lock(int fd, int operation) {
return fcntl_lock(fd, operation, /*ofd=*/ false);
return fcntl_lock(fd, operation, /* ofd= */ false);
}
int unposix_lock(int fd, int operation) {
return fcntl_lock(fd, operation, /*ofd=*/ true);
return fcntl_lock(fd, operation, /* ofd= */ true);
}
void posix_unlockpp(int **fd) {
@@ -167,7 +167,7 @@ void posix_unlockpp(int **fd) {
if (!*fd || **fd < 0)
return;
(void) fcntl_lock(**fd, LOCK_UN, /*ofd=*/ false);
(void) fcntl_lock(**fd, LOCK_UN, /* ofd= */ false);
*fd = NULL;
}
@@ -177,7 +177,7 @@ void unposix_unlockpp(int **fd) {
if (!*fd || **fd < 0)
return;
(void) fcntl_lock(**fd, LOCK_UN, /*ofd=*/ true);
(void) fcntl_lock(**fd, LOCK_UN, /* ofd= */ true);
*fd = NULL;
}
+2 -2
View File
@@ -145,7 +145,7 @@ static LogContext* log_context_free(LogContext *c) {
DEFINE_TRIVIAL_REF_UNREF_FUNC(LogContext, log_context, log_context_free);
LogContext* log_context_new_strv_consume(char **fields) {
LogContext *c = log_context_new_strv(fields, /*owned=*/ true);
LogContext *c = log_context_new_strv(fields, /* owned= */ true);
if (!c)
strv_free(fields);
@@ -153,7 +153,7 @@ LogContext* log_context_new_strv_consume(char **fields) {
}
LogContext* log_context_new_iov_consume(struct iovec *input_iovec, size_t n_input_iovec) {
LogContext *c = log_context_new_iov(input_iovec, n_input_iovec, /*owned=*/ true);
LogContext *c = log_context_new_iov(input_iovec, n_input_iovec, /* owned= */ true);
if (!c)
iovec_array_free(input_iovec, n_input_iovec);
+2 -2
View File
@@ -90,13 +90,13 @@ void _reset_log_level(int *saved_log_level);
_LOG_CONTEXT_PUSH_KEY_VALUE(key, value, UNIQ_T(c, UNIQ))
#define _LOG_CONTEXT_PUSH_STRV(strv, c) \
_unused_ _cleanup_(log_context_unrefp) LogContext *c = log_context_new_strv(strv, /*owned=*/ false);
_unused_ _cleanup_(log_context_unrefp) LogContext *c = log_context_new_strv(strv, /* owned= */ false);
#define LOG_CONTEXT_PUSH_STRV(strv) \
_LOG_CONTEXT_PUSH_STRV(strv, UNIQ_T(c, UNIQ))
#define _LOG_CONTEXT_PUSH_IOV(input_iovec, n_input_iovec, c) \
_unused_ _cleanup_(log_context_unrefp) LogContext *c = log_context_new_iov(input_iovec, n_input_iovec, /*owned=*/ false);
_unused_ _cleanup_(log_context_unrefp) LogContext *c = log_context_new_iov(input_iovec, n_input_iovec, /* owned= */ false);
#define LOG_CONTEXT_PUSH_IOV(input_iovec, n_input_iovec) \
_LOG_CONTEXT_PUSH_IOV(input_iovec, n_input_iovec, UNIQ_T(c, UNIQ))
+1 -1
View File
@@ -374,7 +374,7 @@ int log_syntax_parse_error_internal(
log_syntax_parse_error_internal(unit, config_file, config_line, error, critical, PROJECT_FILE, __LINE__, __func__, lvalue, rvalue)
#define log_syntax_parse_error(unit, config_file, config_line, error, lvalue, rvalue) \
log_syntax_parse_error_full(unit, config_file, config_line, error, /* critical = */ false, lvalue, rvalue)
log_syntax_parse_error_full(unit, config_file, config_line, error, /* critical= */ false, lvalue, rvalue)
#define DEBUG_LOGGING _unlikely_(log_get_max_level() >= LOG_DEBUG)
+1 -1
View File
@@ -113,7 +113,7 @@ int mkdirat_parents_internal(int dir_fd, const char *path, mode_t mode, uid_t ui
/* drop the last component */
path = strndupa_safe(path, e - path);
r = is_dir_at(dir_fd, path, /* follow = */ true);
r = is_dir_at(dir_fd, path, /* follow= */ true);
if (r > 0)
return 0;
if (r == 0)
+2 -2
View File
@@ -1465,11 +1465,11 @@ int path_glob_can_match(const char *pattern, const char *prefix, char **ret) {
const char *p, *q;
int r, s;
r = path_find_first_component(&a, /* accept_dot_dot = */ false, &p);
r = path_find_first_component(&a, /* accept_dot_dot= */ false, &p);
if (r < 0)
return r;
s = path_find_first_component(&b, /* accept_dot_dot = */ false, &q);
s = path_find_first_component(&b, /* accept_dot_dot= */ false, &q);
if (s < 0)
return s;
+1 -1
View File
@@ -29,7 +29,7 @@ int pidfd_check_pidfs(int pid_fd) {
_cleanup_close_ int our_fd = -EBADF;
if (pid_fd < 0) {
our_fd = pidfd_open(getpid_cached(), /* flags = */ 0);
our_fd = pidfd_open(getpid_cached(), /* flags= */ 0);
if (our_fd < 0)
return -errno;
+5 -5
View File
@@ -62,7 +62,7 @@ int proc_cmdline_filter_pid1_args(char **argv, char ***ret) {
if (a[1] == '-') {
if (a[2] == '\0') {
/* "--" is specified, accepting remaining strings. */
r = strv_extend_strv(&filtered, strv_skip(p, 1), /* filter_duplicates = */ false);
r = strv_extend_strv(&filtered, strv_skip(p, 1), /* filter_duplicates= */ false);
if (r < 0)
return r;
break;
@@ -137,7 +137,7 @@ static int proc_cmdline_strv_internal(char ***ret, bool filter_pid1_args) {
if (detect_container() > 0) {
_cleanup_strv_free_ char **args = NULL;
r = pid_get_cmdline_strv(1, /* flags = */ 0, &args);
r = pid_get_cmdline_strv(1, /* flags= */ 0, &args);
if (r < 0)
return r;
@@ -159,7 +159,7 @@ static int proc_cmdline_strv_internal(char ***ret, bool filter_pid1_args) {
}
int proc_cmdline_strv(char ***ret) {
return proc_cmdline_strv_internal(ret, /* filter_pid1_args = */ false);
return proc_cmdline_strv_internal(ret, /* filter_pid1_args= */ false);
}
static char *mangle_word(const char *word, ProcCmdlineFlags flags) {
@@ -216,7 +216,7 @@ int proc_cmdline_parse(proc_cmdline_parse_t parse_item, void *data, ProcCmdlineF
* for proc_cmdline_parse(), let's make this clear. */
assert(!(flags & (PROC_CMDLINE_VALUE_OPTIONAL|PROC_CMDLINE_TRUE_WHEN_MISSING)));
r = proc_cmdline_strv_internal(&args, /* filter_pid1_args = */ true);
r = proc_cmdline_strv_internal(&args, /* filter_pid1_args= */ true);
if (r < 0)
return r;
@@ -326,7 +326,7 @@ int proc_cmdline_get_key(const char *key, ProcCmdlineFlags flags, char **ret_val
if (FLAGS_SET(flags, PROC_CMDLINE_VALUE_OPTIONAL) && !ret_value)
return -EINVAL;
r = proc_cmdline_strv_internal(&args, /* filter_pid1_args = */ true);
r = proc_cmdline_strv_internal(&args, /* filter_pid1_args= */ true);
if (r < 0)
return r;
+3 -3
View File
@@ -249,7 +249,7 @@ int pid_get_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags, ch
/* Drop trailing NULs, otherwise strv_parse_nulstr() adds additional empty strings at the end.
* See also issue #21186. */
args = strv_parse_nulstr_full(t, k, /* drop_trailing_nuls = */ true);
args = strv_parse_nulstr_full(t, k, /* drop_trailing_nuls= */ true);
if (!args)
return -ENOMEM;
@@ -315,7 +315,7 @@ int pid_get_cmdline_strv(pid_t pid, ProcessCmdlineFlags flags, char ***ret) {
if (r < 0)
return r;
args = strv_parse_nulstr_full(t, k, /* drop_trailing_nuls = */ true);
args = strv_parse_nulstr_full(t, k, /* drop_trailing_nuls= */ true);
if (!args)
return -ENOMEM;
@@ -2339,7 +2339,7 @@ int read_errno(int errno_fd) {
/* The issue here is that it's impossible to distinguish between an error code returned by child and
* IO error arose when reading it. So, the function logs errors and return EIO for the later case. */
ssize_t n = loop_read(errno_fd, &r, sizeof(r), /* do_poll = */ false);
ssize_t n = loop_read(errno_fd, &r, sizeof(r), /* do_poll= */ false);
if (n < 0) {
log_debug_errno(n, "Failed to read errno: %m");
return -EIO;
+1 -1
View File
@@ -183,7 +183,7 @@ int convert_meminfo_value_to_uint64_bytes(const char *s, uint64_t *ret) {
assert(s);
assert(ret);
r = extract_first_word(&s, &w, /* separators = */ NULL, /* flags = */ 0);
r = extract_first_word(&s, &w, /* separators= */ NULL, /* flags= */ 0);
if (r < 0)
return r;
if (r == 0)
+1 -1
View File
@@ -5,7 +5,7 @@
typedef struct RateLimit {
usec_t interval; /* Keep those two fields first so they can be initialized easily: */
unsigned burst; /* RateLimit rl = { INTERVAL, BURST }; */
unsigned burst; /* RateLimit rl = { INTERVAL, BURST }; */
unsigned num;
usec_t begin;
} RateLimit;
+9 -9
View File
@@ -230,9 +230,9 @@ int recurse_dir(
r = func(RECURSE_DIR_SKIP_OPEN_DIR_ERROR_BASE + errno,
p,
dir_fd,
/* inode_fd = */ -EBADF,
/* inode_fd= */ -EBADF,
i,
/* sx = */ NULL,
/* sx= */ NULL,
userdata);
if (r == RECURSE_DIR_LEAVE_DIRECTORY)
break;
@@ -274,9 +274,9 @@ int recurse_dir(
r = func(RECURSE_DIR_SKIP_OPEN_INODE_ERROR_BASE + errno,
p,
dir_fd,
/* inode_fd = */ -EBADF,
/* inode_fd= */ -EBADF,
i,
/* sx = */ NULL,
/* sx= */ NULL,
userdata);
if (r == RECURSE_DIR_LEAVE_DIRECTORY)
break;
@@ -322,9 +322,9 @@ int recurse_dir(
r = func(RECURSE_DIR_SKIP_STAT_INODE_ERROR_BASE + errno,
p,
dir_fd,
/* inode_fd = */ -EBADF,
/* inode_fd= */ -EBADF,
i,
/* sx = */ NULL,
/* sx= */ NULL,
userdata);
if (r == RECURSE_DIR_LEAVE_DIRECTORY)
break;
@@ -352,9 +352,9 @@ int recurse_dir(
r = func(RECURSE_DIR_SKIP_STAT_INODE_ERROR_BASE + EISDIR,
p,
dir_fd,
/* inode_fd = */ -EBADF,
/* inode_fd= */ -EBADF,
i,
/* sx = */ NULL,
/* sx= */ NULL,
userdata);
if (r == RECURSE_DIR_LEAVE_DIRECTORY)
break;
@@ -384,7 +384,7 @@ int recurse_dir(
if (sx_valid && FLAGS_SET(sx.stx_attributes_mask, STATX_ATTR_MOUNT_ROOT))
is_mount = FLAGS_SET(sx.stx_attributes, STATX_ATTR_MOUNT_ROOT);
else {
r = is_mount_point_at(dir_fd, i->d_name, /* flags = */ 0);
r = is_mount_point_at(dir_fd, i->d_name, /* flags= */ 0);
if (r < 0)
log_debug_errno(r, "Failed to determine whether %s is a submount, assuming not: %m", p);
+1 -1
View File
@@ -464,7 +464,7 @@ int pid_getrlimit(pid_t pid, int resource, struct rlimit *ret) {
const char *p = procfs_file_alloca(pid, "limits");
_cleanup_free_ char *limits = NULL;
r = read_full_file(p, &limits, /* ret_size = */ NULL);
r = read_full_file(p, &limits, /* ret_size= */ NULL);
if (r < 0)
return -EPERM; /* propagate original permission error if we can't access the limits file */
+1 -1
View File
@@ -1320,7 +1320,7 @@ ssize_t flush_mqueue(int fd) {
return -ENOMEM;
}
l = mq_receive(fd, buf, attr.mq_msgsize, /* msg_prio = */ NULL);
l = mq_receive(fd, buf, attr.mq_msgsize, /* msg_prio= */ NULL);
if (l < 0) {
if (errno == EINTR)
continue;
+3 -3
View File
@@ -332,7 +332,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
x = ((new_length - need_space) * percent + 50) / 100;
assert(x <= new_length - need_space);
write_ellipsis(mempcpy(t, s, x), /* unicode = */ false);
write_ellipsis(mempcpy(t, s, x), /* unicode= */ false);
suffix_len = new_length - x - need_space;
memcpy(t + x + 3, s + old_length - suffix_len, suffix_len);
*(t + x + 3 + suffix_len) = '\0';
@@ -454,7 +454,7 @@ char* ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
return NULL;
memcpy_safe(e, s, len);
write_ellipsis(e + len, /* unicode = */ true);
write_ellipsis(e + len, /* unicode= */ true);
char *dst = e + len + 3;
@@ -533,7 +533,7 @@ char* cellescape(char *buf, size_t len, const char *s) {
}
if (i + 4 <= len) /* yay, enough space */
i += write_ellipsis(buf + i, /* unicode = */ false);
i += write_ellipsis(buf + i, /* unicode= */ false);
else if (i + 3 <= len) { /* only space for ".." */
buf[i++] = '.';
buf[i++] = '.';
+1 -1
View File
@@ -925,7 +925,7 @@ int strv_extend_joined_with_size_sentinel(char ***l, size_t *n, ...) {
va_list ap;
va_start(ap, n);
char *x = strextendv_with_separator(/* x= */ NULL, /* separator=*/ NULL, ap);
char *x = strextendv_with_separator(/* x= */ NULL, /* separator= */ NULL, ap);
va_end(ap);
if (!x)
return -ENOMEM;
+5 -5
View File
@@ -377,7 +377,7 @@ int ask_string_full(
/* n_columns= */ SIZE_MAX,
/* column_width= */ SIZE_MAX,
/* ellipsize_percentage= */ 0,
/* grey_prefix=*/ string,
/* grey_prefix= */ string,
/* with_numbers= */ false);
if (r < 0)
goto fail;
@@ -730,7 +730,7 @@ int acquire_terminal(
.fd = notify,
.events = POLLIN,
},
/* n_fds = */ 1,
/* n_fds= */ 1,
left,
&poll_ss);
if (r < 0)
@@ -1095,7 +1095,7 @@ bool tty_is_vc(const char *tty) {
* about whether it's strictly valid, but only asking "does this fall into the vt category?", for which
* "yes" seems to be a better answer. */
return vtnr_from_tty_raw(tty, /* ret = */ NULL) >= 0;
return vtnr_from_tty_raw(tty, /* ret= */ NULL) >= 0;
}
bool tty_is_console(const char *tty) {
@@ -1387,7 +1387,7 @@ int proc_cmdline_tty_size(const char *tty, unsigned *ret_rows, unsigned *ret_col
if (!colskey)
return -ENOMEM;
r = proc_cmdline_get_key_many(/* flags = */ 0,
r = proc_cmdline_get_key_many(/* flags= */ 0,
rowskey, &rowsvalue,
colskey, &colsvalue);
if (r < 0)
@@ -1655,7 +1655,7 @@ int openpt_allocate_in_namespace(
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;
r = pidref_namespace_open(pidref, &pidnsfd, &mntnsfd, /* ret_netns_fd = */ NULL, &usernsfd, &rootfd);
r = pidref_namespace_open(pidref, &pidnsfd, &mntnsfd, /* ret_netns_fd= */ NULL, &usernsfd, &rootfd);
if (r < 0)
return r;
+12 -12
View File
@@ -1060,31 +1060,31 @@ int parse_timestamp(const char *t, usec_t *ret) {
size_t t_len = strlen(t);
if (t_len > 2 && t[t_len - 1] == 'Z') {
/* Try to parse as RFC3339-style welded UTC: "1985-04-12T23:20:50.52Z" */
r = parse_timestamp_impl(t, t_len - 1, /* utc = */ true, /* isdst = */ -1, /* gmtoff = */ 0, ret);
r = parse_timestamp_impl(t, t_len - 1, /* utc= */ true, /* isdst= */ -1, /* gmtoff= */ 0, ret);
if (r >= 0)
return r;
}
/* RFC3339-style welded offset: "1990-12-31T15:59:60-08:00" */
if (t_len > 7 && IN_SET(t[t_len - 6], '+', '-') && t[t_len - 7] != ' ' && parse_gmtoff(&t[t_len - 6], &gmtoff) >= 0)
return parse_timestamp_impl(t, t_len - 6, /* utc = */ true, /* isdst = */ -1, gmtoff, ret);
return parse_timestamp_impl(t, t_len - 6, /* utc= */ true, /* isdst= */ -1, gmtoff, ret);
const char *tz = strrchr(t, ' ');
if (!tz)
return parse_timestamp_impl(t, /* max_len = */ SIZE_MAX, /* utc = */ false, /* isdst = */ -1, /* gmtoff = */ 0, ret);
return parse_timestamp_impl(t, /* max_len= */ SIZE_MAX, /* utc= */ false, /* isdst= */ -1, /* gmtoff= */ 0, ret);
size_t max_len = tz - t;
tz++;
/* Shortcut, parse the string as UTC. */
if (streq(tz, "UTC"))
return parse_timestamp_impl(t, max_len, /* utc = */ true, /* isdst = */ -1, /* gmtoff = */ 0, ret);
return parse_timestamp_impl(t, max_len, /* utc= */ true, /* isdst= */ -1, /* gmtoff= */ 0, ret);
/* If the timezone is compatible with RFC-822/ISO 8601 (e.g. +06, or -03:00) then parse the string as
* UTC and shift the result. Note, this must be earlier than the timezone check with tzname[], as
* tzname[] may be in the same format. */
if (parse_gmtoff(tz, &gmtoff) >= 0)
return parse_timestamp_impl(t, max_len, /* utc = */ true, /* isdst = */ -1, gmtoff, ret);
return parse_timestamp_impl(t, max_len, /* utc= */ true, /* isdst= */ -1, gmtoff, ret);
/* Check if the last word matches tzname[] of the local timezone. Note, this must be done earlier
* than the check by timezone_is_valid() below, as some short timezone specifications have their own
@@ -1096,7 +1096,7 @@ int parse_timestamp(const char *t, usec_t *ret) {
continue;
/* The specified timezone matches tzname[] of the local timezone. */
return parse_timestamp_impl(t, max_len, /* utc = */ false, /* isdst = */ j, /* gmtoff = */ 0, ret);
return parse_timestamp_impl(t, max_len, /* utc= */ false, /* isdst= */ j, /* gmtoff= */ 0, ret);
}
/* If the last word is a valid timezone file (e.g. Asia/Tokyo), then save the current timezone, apply
@@ -1104,15 +1104,15 @@ int parse_timestamp(const char *t, usec_t *ret) {
if (timezone_is_valid(tz, LOG_DEBUG)) {
SAVE_TIMEZONE;
if (setenv("TZ", tz, /* overwrite = */ true) < 0)
if (setenv("TZ", tz, /* overwrite= */ true) < 0)
return negative_errno();
return parse_timestamp_impl(t, max_len, /* utc = */ false, /* isdst = */ -1, /* gmtoff = */ 0, ret);
return parse_timestamp_impl(t, max_len, /* utc= */ false, /* isdst= */ -1, /* gmtoff= */ 0, ret);
}
/* Otherwise, assume that the last word is a part of the time and try to parse the whole string as a
* local time. */
return parse_timestamp_impl(t, SIZE_MAX, /* utc = */ false, /* isdst = */ -1, /* gmtoff = */ 0, ret);
return parse_timestamp_impl(t, SIZE_MAX, /* utc= */ false, /* isdst= */ -1, /* gmtoff= */ 0, ret);
}
static const char* extract_multiplier(const char *p, usec_t *ret) {
@@ -1172,7 +1172,7 @@ int parse_time(const char *t, usec_t *ret, usec_t default_unit) {
assert(t);
assert(default_unit > 0);
p = skip_leading_chars(t, /* bad = */ NULL);
p = skip_leading_chars(t, /* bad= */ NULL);
s = startswith(p, "infinity");
if (s) {
if (!in_charset(s, WHITESPACE))
@@ -1190,7 +1190,7 @@ int parse_time(const char *t, usec_t *ret, usec_t default_unit) {
long long l;
char *e;
p = skip_leading_chars(p, /* bad = */ NULL);
p = skip_leading_chars(p, /* bad= */ NULL);
if (*p == 0) {
if (!something)
return -EINVAL;
@@ -1628,7 +1628,7 @@ int verify_timezone(const char *name, int log_level) {
void reset_timezonep(char **p) {
assert(p);
(void) set_unset_env("TZ", *p, /* overwrite = */ true);
(void) set_unset_env("TZ", *p, /* overwrite= */ true);
tzset();
*p = mfree(*p);
}
+2 -2
View File
@@ -125,11 +125,11 @@ char* format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) _warn_unus
_warn_unused_result_
static inline char* format_timestamp_relative(char *buf, size_t l, usec_t t) {
return format_timestamp_relative_full(buf, l, t, CLOCK_REALTIME, /* implicit_left = */ false);
return format_timestamp_relative_full(buf, l, t, CLOCK_REALTIME, /* implicit_left= */ false);
}
_warn_unused_result_
static inline char* format_timestamp_relative_monotonic(char *buf, size_t l, usec_t t) {
return format_timestamp_relative_full(buf, l, t, CLOCK_MONOTONIC, /* implicit_left = */ false);
return format_timestamp_relative_full(buf, l, t, CLOCK_MONOTONIC, /* implicit_left= */ false);
}
_warn_unused_result_
+3 -3
View File
@@ -202,7 +202,7 @@ int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
* /foo/bar/.#<extra>waldoXXXXXX
*/
return tempfn_build(p, extra, "XXXXXX", /* child = */ false, ret);
return tempfn_build(p, extra, "XXXXXX", /* child= */ false, ret);
}
int tempfn_random(const char *p, const char *extra, char **ret) {
@@ -222,7 +222,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
if (asprintf(&s, "%016" PRIx64, random_u64()) < 0)
return -ENOMEM;
return tempfn_build(p, extra, s, /* child = */ false, ret);
return tempfn_build(p, extra, s, /* child= */ false, ret);
}
int tempfn_random_child(const char *p, const char *extra, char **ret) {
@@ -246,7 +246,7 @@ int tempfn_random_child(const char *p, const char *extra, char **ret) {
if (asprintf(&s, "%016" PRIx64, random_u64()) < 0)
return -ENOMEM;
return tempfn_build(p, extra, s, /* child = */ true, ret);
return tempfn_build(p, extra, s, /* child= */ true, ret);
}
int open_tmpfile_unlinkable(const char *directory, int flags) {
+2 -2
View File
@@ -125,7 +125,7 @@ int uid_range_add_str(UIDRange **range, const char *s) {
if (r < 0)
return r;
return uid_range_add_internal(range, start, end - start + 1, /* coalesce = */ true);
return uid_range_add_internal(range, start, end - start + 1, /* coalesce= */ true);
}
int uid_range_next_lower(const UIDRange *range, uid_t *uid) {
@@ -274,7 +274,7 @@ int uid_range_load_userns(const char *path, UIDRangeUsernsMode mode, UIDRange **
&range,
IN_SET(mode, UID_RANGE_USERNS_INSIDE, GID_RANGE_USERNS_INSIDE) ? uid_base : uid_shift,
uid_range,
/* coalesce = */ false);
/* coalesce= */ false);
if (r < 0)
return r;
}
+1 -1
View File
@@ -814,7 +814,7 @@ int running_in_chroot(void) {
if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0)
return 0;
r = inode_same("/proc/1/root", "/", /* flags = */ 0);
r = inode_same("/proc/1/root", "/", /* flags= */ 0);
if (r == -ENOENT) {
r = proc_mounted();
if (r == 0) {
+2 -2
View File
@@ -473,9 +473,9 @@ int fd_setcrtime(int fd, usec_t usec) {
usec = now(CLOCK_REALTIME);
le = htole64((uint64_t) usec);
return xsetxattr_full(fd, /* path = */ NULL, AT_EMPTY_PATH,
return xsetxattr_full(fd, /* path= */ NULL, AT_EMPTY_PATH,
"user.crtime_usec", (const char*) &le, sizeof(le),
/* xattr_flags = */ 0);
/* xattr_flags= */ 0);
}
bool xattr_is_acl(const char *name) {