mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
Bugprone argument comment - round 4 (#37380)
Follow up from https://github.com/systemd/systemd/pull/37356
This commit is contained in:
@@ -701,7 +701,7 @@ int cg_get_xattr_bool(const char *path, const char *name) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return getxattr_at_bool(AT_FDCWD, fs, name, /* flags= */ 0);
|
||||
return getxattr_at_bool(AT_FDCWD, fs, name, /* at_flags= */ 0);
|
||||
}
|
||||
|
||||
int cg_remove_xattr(const char *path, const char *name) {
|
||||
@@ -2176,11 +2176,11 @@ int cg_is_delegated_fd(int fd) {
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
r = getxattr_at_bool(fd, /* path= */ NULL, "trusted.delegate", /* flags= */ 0);
|
||||
r = getxattr_at_bool(fd, /* path= */ NULL, "trusted.delegate", /* at_flags= */ 0);
|
||||
if (!ERRNO_IS_NEG_XATTR_ABSENT(r))
|
||||
return r;
|
||||
|
||||
r = getxattr_at_bool(fd, /* path= */ NULL, "user.delegate", /* flags= */ 0);
|
||||
r = getxattr_at_bool(fd, /* path= */ NULL, "user.delegate", /* at_flags= */ 0);
|
||||
return ERRNO_IS_NEG_XATTR_ABSENT(r) ? false : r;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ bool unsafe_transition(const struct stat *a, const struct stat *b);
|
||||
/* How many iterations to execute before returning -ELOOP */
|
||||
#define CHASE_MAX 32
|
||||
|
||||
int chase(const char *path_with_prefix, const char *root, ChaseFlags chase_flags, char **ret_path, int *ret_fd);
|
||||
int chase(const char *path_with_prefix, const char *root, ChaseFlags flags, char **ret_path, int *ret_fd);
|
||||
|
||||
int chaseat_prefix_root(const char *path, const char *root, char **ret);
|
||||
int chase_extract_filename(const char *path, const char *root, char **ret);
|
||||
|
||||
@@ -123,7 +123,7 @@ static int extension_release_strict_xattr_value(int extension_release_fd, const
|
||||
assert(filename);
|
||||
|
||||
/* No xattr or cannot parse it? Then skip this. */
|
||||
r = getxattr_at_bool(extension_release_fd, /* path= */ NULL, "user.extension-release.strict", /* flags= */ 0);
|
||||
r = getxattr_at_bool(extension_release_fd, /* path= */ NULL, "user.extension-release.strict", /* at_flags= */ 0);
|
||||
if (ERRNO_IS_NEG_XATTR_ABSENT(r))
|
||||
return log_debug_errno(r, "%s/%s does not have user.extension-release.strict xattr, ignoring.",
|
||||
extension_release_dir_path, filename);
|
||||
|
||||
@@ -1119,7 +1119,7 @@ int resolve_dev_console(char **ret) {
|
||||
* is a sign for container setups). */
|
||||
|
||||
_cleanup_free_ char *chased = NULL;
|
||||
r = chase("/dev/console", /* root= */ NULL, /* chase_flags= */ 0, &chased, /* ret_fd= */ NULL);
|
||||
r = chase("/dev/console", /* root= */ NULL, /* flags= */ 0, &chased, /* ret_fd= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!path_equal(chased, "/dev/console")) {
|
||||
|
||||
@@ -143,7 +143,7 @@ int openpt_allocate(int flags, char **ret_peer);
|
||||
int openpt_allocate_in_namespace(const PidRef *pidref, int flags, char **ret_peer);
|
||||
|
||||
int vt_restore(int fd);
|
||||
int vt_release(int fd, bool restore_vt);
|
||||
int vt_release(int fd, bool restore);
|
||||
|
||||
void get_log_colors(int priority, const char **on, const char **off, const char **highlight);
|
||||
|
||||
|
||||
@@ -685,7 +685,7 @@ static char* context_fallback_icon_name(Context *c) {
|
||||
|
||||
static int context_update_kernel_hostname(
|
||||
Context *c,
|
||||
const char *transient_hn) {
|
||||
const char *transient_hostname) {
|
||||
|
||||
_cleanup_free_ char *_hn_free = NULL;
|
||||
const char *hn;
|
||||
@@ -700,8 +700,8 @@ static int context_update_kernel_hostname(
|
||||
hns = HOSTNAME_STATIC;
|
||||
|
||||
/* ... the transient hostname, (ie: DHCP) comes next ... */
|
||||
} else if (transient_hn) {
|
||||
hn = transient_hn;
|
||||
} else if (transient_hostname) {
|
||||
hn = transient_hostname;
|
||||
hns = HOSTNAME_TRANSIENT;
|
||||
|
||||
/* ... and the ultimate fallback */
|
||||
|
||||
@@ -567,7 +567,7 @@ static int device_new_from_devname(sd_device **ret, const char *devname, bool st
|
||||
|
||||
_cleanup_free_ char *resolved = NULL;
|
||||
struct stat st;
|
||||
r = chase_and_stat(devname, /* root = */ NULL, /* flags = */ 0, &resolved, &st);
|
||||
r = chase_and_stat(devname, /* root = */ NULL, /* chase_flags = */ 0, &resolved, &st);
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
return -ENODEV;
|
||||
if (r < 0)
|
||||
|
||||
@@ -1437,7 +1437,7 @@ int link_reconfigure_impl(Link *link, LinkReconfigurationFlag flags) {
|
||||
} else {
|
||||
/* Otherwise, stop DHCP client and friends unconditionally, and drop all dynamic
|
||||
* configurations like DHCP address and routes. */
|
||||
r = link_stop_engines(link, /* may_keep_dhcp = */ false);
|
||||
r = link_stop_engines(link, /* may_keep_dynamic = */ false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ static CreditEntropy may_credit(int seed_fd) {
|
||||
}
|
||||
|
||||
/* Determine if the file is marked as creditable */
|
||||
r = getxattr_at_bool(seed_fd, /* path= */ NULL, "user.random-seed-creditable", /* flags= */ 0);
|
||||
r = getxattr_at_bool(seed_fd, /* path= */ NULL, "user.random-seed-creditable", /* at_flags= */ 0);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_XATTR_ABSENT(r))
|
||||
log_debug_errno(r, "Seed file is not marked as creditable, not crediting.");
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef struct AskPasswordRequest {
|
||||
|
||||
int ask_password_tty(const AskPasswordRequest *req, AskPasswordFlags flags, char ***ret);
|
||||
int ask_password_plymouth(const AskPasswordRequest *req, AskPasswordFlags flags, char ***ret);
|
||||
int ask_password_agent(const AskPasswordRequest *req, AskPasswordFlags flag, char ***ret);
|
||||
int ask_password_auto(const AskPasswordRequest *req, AskPasswordFlags flag, char ***ret);
|
||||
int ask_password_agent(const AskPasswordRequest *req, AskPasswordFlags flags, char ***ret);
|
||||
int ask_password_auto(const AskPasswordRequest *req, AskPasswordFlags flags, char ***ret);
|
||||
|
||||
int acquire_user_ask_password_directory(char **ret);
|
||||
|
||||
@@ -1565,7 +1565,7 @@ int boot_config_load_auto(
|
||||
int boot_config_augment_from_loader(
|
||||
BootConfig *config,
|
||||
char **found_by_loader,
|
||||
bool only_auto) {
|
||||
bool auto_only) {
|
||||
|
||||
static const BootEntryAddons no_addons = (BootEntryAddons) {};
|
||||
static const char *const title_table[] = {
|
||||
@@ -1595,7 +1595,7 @@ int boot_config_augment_from_loader(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (only_auto && !startswith(*i, "auto-"))
|
||||
if (auto_only && !startswith(*i, "auto-"))
|
||||
continue;
|
||||
|
||||
c = strdup(*i);
|
||||
|
||||
@@ -132,7 +132,7 @@ int boot_config_load_type1(
|
||||
int boot_config_finalize(BootConfig *config);
|
||||
int boot_config_load(BootConfig *config, const char *esp_path, const char *xbootldr_path);
|
||||
int boot_config_load_auto(BootConfig *config, const char *override_esp_path, const char *override_xbootldr_path);
|
||||
int boot_config_augment_from_loader(BootConfig *config, char **list, bool only_auto);
|
||||
int boot_config_augment_from_loader(BootConfig *config, char **list, bool auto_only);
|
||||
|
||||
int boot_config_select_special_entries(BootConfig *config, bool skip_efivars);
|
||||
|
||||
|
||||
@@ -1758,7 +1758,7 @@ static int pick_up_credential_one(
|
||||
AT_FDCWD, target_path,
|
||||
/* open_flags= */ 0,
|
||||
0644,
|
||||
/* flags= */ 0);
|
||||
/* copy_flags= */ 0);
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to copy credential %s → file %s: %m",
|
||||
credential_name, target_path);
|
||||
|
||||
@@ -669,7 +669,7 @@ static int compare_arch(Architecture a, Architecture b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool image_filter_test(const ImageFilter *filter, PartitionDesignator d, const char *name) {
|
||||
static bool image_filter_test(const ImageFilter *filter, PartitionDesignator d, const char *label) {
|
||||
assert(d < _PARTITION_DESIGNATOR_MAX);
|
||||
|
||||
if (d < 0) /* For unspecified designators we have no filter expression */
|
||||
@@ -678,7 +678,7 @@ static bool image_filter_test(const ImageFilter *filter, PartitionDesignator d,
|
||||
if (!filter || !filter->pattern[d])
|
||||
return true;
|
||||
|
||||
return fnmatch(filter->pattern[d], strempty(name), FNM_NOESCAPE) == 0;
|
||||
return fnmatch(filter->pattern[d], strempty(label), FNM_NOESCAPE) == 0;
|
||||
}
|
||||
|
||||
static int dissect_image(
|
||||
|
||||
@@ -10,8 +10,8 @@ static void test_policy(const ImagePolicy *p, const char *name) {
|
||||
_cleanup_free_ char *as_string = NULL, *as_string_simplified = NULL;
|
||||
_cleanup_free_ ImagePolicy *parsed = NULL;
|
||||
|
||||
assert_se(image_policy_to_string(p, /* simplified= */ false, &as_string) >= 0);
|
||||
assert_se(image_policy_to_string(p, /* simplified= */ true, &as_string_simplified) >= 0);
|
||||
assert_se(image_policy_to_string(p, /* simplify= */ false, &as_string) >= 0);
|
||||
assert_se(image_policy_to_string(p, /* simplify= */ true, &as_string_simplified) >= 0);
|
||||
|
||||
printf("%s%s", ansi_underline(), name);
|
||||
|
||||
@@ -40,17 +40,17 @@ static void test_policy(const ImagePolicy *p, const char *name) {
|
||||
if (f < 0) {
|
||||
f = image_policy_get_exhaustively(p, d);
|
||||
assert_se(f >= 0);
|
||||
assert_se(partition_policy_flags_to_string(f, /* simplified= */ true, &k) >= 0);
|
||||
assert_se(partition_policy_flags_to_string(f, /* simplify= */ true, &k) >= 0);
|
||||
|
||||
printf("%s\t%s → n/a (exhaustively: %s)%s\n", ansi_grey(), partition_designator_to_string(d), k, ansi_normal());
|
||||
} else {
|
||||
assert_se(partition_policy_flags_to_string(f, /* simplified= */ true, &k) >= 0);
|
||||
assert_se(partition_policy_flags_to_string(f, /* simplify= */ true, &k) >= 0);
|
||||
printf("\t%s → %s\n", partition_designator_to_string(d), k);
|
||||
}
|
||||
}
|
||||
|
||||
_cleanup_free_ char *w = NULL;
|
||||
assert_se(partition_policy_flags_to_string(image_policy_default(p), /* simplified= */ true, &w) >= 0);
|
||||
assert_se(partition_policy_flags_to_string(image_policy_default(p), /* simplify= */ true, &w) >= 0);
|
||||
printf("\tdefault → %s\n", w);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,61 +35,61 @@ TEST(udev_rule_parse_value) {
|
||||
* parsed: valid operand
|
||||
* use the following command to help generate textual C strings:
|
||||
* python3 -c 'import json; print(json.dumps(input()))' */
|
||||
test_udev_rule_parse_value_one("\"valid operand\"", "valid operand", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("\"valid operand\"", "valid operand", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: "va'l\'id\"op\"erand"
|
||||
* parsed: va'l\'id"op"erand */
|
||||
test_udev_rule_parse_value_one("\"va'l\\'id\\\"op\\\"erand\"", "va'l\\'id\"op\"erand", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("no quotes", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("\"\\\\a\\b\\x\\y\"", "\\\\a\\b\\x\\y", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("\"reject\0nul\"", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("\"va'l\\'id\\\"op\\\"erand\"", "va'l\\'id\"op\"erand", /* expected_case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("no quotes", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("\"\\\\a\\b\\x\\y\"", "\\\\a\\b\\x\\y", /* expected_case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("\"reject\0nul\"", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: e"" */
|
||||
test_udev_rule_parse_value_one("e\"\"", "", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"\"", "", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"1234" */
|
||||
test_udev_rule_parse_value_one("e\"1234\"", "1234", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"1234\"", "1234", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"\"" */
|
||||
test_udev_rule_parse_value_one("e\"\\\"\"", "\"", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"\\\"\"", "\"", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"\ */
|
||||
test_udev_rule_parse_value_one("e\"\\", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("e\"\\", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: e"\" */
|
||||
test_udev_rule_parse_value_one("e\"\\\"", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("e\"\\\"", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: e"\\" */
|
||||
test_udev_rule_parse_value_one("e\"\\\\\"", "\\", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"\\\\\"", "\\", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"\\\" */
|
||||
test_udev_rule_parse_value_one("e\"\\\\\\\"", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("e\"\\\\\\\"", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: e"\\\"" */
|
||||
test_udev_rule_parse_value_one("e\"\\\\\\\"\"", "\\\"", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"\\\\\\\"\"", "\\\"", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"\\\\" */
|
||||
test_udev_rule_parse_value_one("e\"\\\\\\\\\"", "\\\\", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"\\\\\\\\\"", "\\\\", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"operand with newline\n" */
|
||||
test_udev_rule_parse_value_one("e\"operand with newline\\n\"", "operand with newline\n", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"operand with newline\\n\"", "operand with newline\n", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"single\rcharacter\t\aescape\bsequence" */
|
||||
test_udev_rule_parse_value_one(
|
||||
"e\"single\\rcharacter\\t\\aescape\\bsequence\"", "single\rcharacter\t\aescape\bsequence", /* case_insensitive = */ false, 0);
|
||||
"e\"single\\rcharacter\\t\\aescape\\bsequence\"", "single\rcharacter\t\aescape\bsequence", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: e"reject\invalid escape sequence" */
|
||||
test_udev_rule_parse_value_one("e\"reject\\invalid escape sequence", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("e\"reject\\invalid escape sequence", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: e"\ */
|
||||
test_udev_rule_parse_value_one("e\"\\", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("e\"\\", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: "s\u1d1c\u1d04\u029c \u1d1c\u0274\u026a\u1d04\u1d0f\u1d05\u1d07 \U0001d568\U0001d560\U0001d568" */
|
||||
test_udev_rule_parse_value_one(
|
||||
"e\"s\\u1d1c\\u1d04\\u029c \\u1d1c\\u0274\\u026a\\u1d04\\u1d0f\\u1d05\\u1d07 \\U0001d568\\U0001d560\\U0001d568\"",
|
||||
"s\xe1\xb4\x9c\xe1\xb4\x84\xca\x9c \xe1\xb4\x9c\xc9\xb4\xc9\xaa\xe1\xb4\x84\xe1\xb4\x8f\xe1\xb4\x85\xe1\xb4\x87 \xf0\x9d\x95\xa8\xf0\x9d\x95\xa0\xf0\x9d\x95\xa8",
|
||||
/* case_insensitive = */ false, 0);
|
||||
/* expected_case_insensitive = */ false, 0);
|
||||
/* input: i"ABCD1234" */
|
||||
test_udev_rule_parse_value_one("i\"ABCD1234\"", "ABCD1234", /* case_insensitive = */ true, 0);
|
||||
test_udev_rule_parse_value_one("i\"ABCD1234\"", "ABCD1234", /* expected_case_insensitive = */ true, 0);
|
||||
/* input: i"ABCD1234" */
|
||||
test_udev_rule_parse_value_one("e\"ABCD1234\"", "ABCD1234", /* case_insensitive = */ false, 0);
|
||||
test_udev_rule_parse_value_one("e\"ABCD1234\"", "ABCD1234", /* expected_case_insensitive = */ false, 0);
|
||||
/* input: ei"\\"ABCD1234 */
|
||||
test_udev_rule_parse_value_one("ei\"\\\\ABCD1234\"", "\\ABCD1234", /* case_insensitive = */ true, 0);
|
||||
test_udev_rule_parse_value_one("ei\"\\\\ABCD1234\"", "\\ABCD1234", /* expected_case_insensitive = */ true, 0);
|
||||
/* input: ie"\\"ABCD1234 */
|
||||
test_udev_rule_parse_value_one("ie\"\\\\ABCD1234\"", "\\ABCD1234", /* case_insensitive = */ true, 0);
|
||||
test_udev_rule_parse_value_one("ie\"\\\\ABCD1234\"", "\\ABCD1234", /* expected_case_insensitive = */ true, 0);
|
||||
/* input: i */
|
||||
test_udev_rule_parse_value_one("i", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("i", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: ee"" */
|
||||
test_udev_rule_parse_value_one("ee\"\"", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("ee\"\"", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: iei"" */
|
||||
test_udev_rule_parse_value_one("iei\"\"", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("iei\"\"", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
/* input: a"" */
|
||||
test_udev_rule_parse_value_one("a\"\"", NULL, /* case_insensitive = */ false, -EINVAL);
|
||||
test_udev_rule_parse_value_one("a\"\"", NULL, /* expected_case_insensitive = */ false, -EINVAL);
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN(LOG_DEBUG);
|
||||
|
||||
@@ -2330,7 +2330,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
|
||||
const char *e = secure_getenv("SYSTEMD_VMSPAWN_QEMU_EXTRA");
|
||||
if (e) {
|
||||
r = strv_split_and_extend_full(&cmdline, e,
|
||||
/* separator = */ NULL, /* filter_duplicates = */ false,
|
||||
/* separators = */ NULL, /* filter_duplicates = */ false,
|
||||
EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse $SYSTEMD_VMSPAWN_QEMU_EXTRA: %m");
|
||||
|
||||
Reference in New Issue
Block a user