mirror of
https://github.com/systemd/systemd
synced 2024-07-24 03:36:24 +00:00
tree-wise: drop unnecessary use of proc_cmdline_key_streq()
If the key does not contain '-' or '_', then it is not necessary to use proc_cmdline_key_streq(), and streq() is sufficient. This also adds missing assertions about 'key' argument.
This commit is contained in:
parent
91acee9906
commit
a8d3315ba4
|
@ -1355,6 +1355,8 @@ static int add_mounts_from_creds(bool prefix_sysroot) {
|
|||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
assert(key);
|
||||
|
||||
/* root=, usr=, usrfstype= and roofstype= may occur more than once, the last
|
||||
* instance should take precedence. In the case of multiple rootflags=
|
||||
* or usrflags= the arguments should be concatenated */
|
||||
|
|
|
@ -904,7 +904,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
else
|
||||
arg_enabled = r;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "root")) {
|
||||
} else if (streq(key, "root")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
@ -917,7 +917,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
log_debug("Disabling root partition auto-detection, root= is defined.");
|
||||
}
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "roothash")) {
|
||||
} else if (streq(key, "roothash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
@ -941,14 +941,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
if (!strextend_with_separator(&arg_root_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "rw") && !value)
|
||||
} else if (streq(key, "rw") && !value)
|
||||
arg_root_rw = true;
|
||||
else if (proc_cmdline_key_streq(key, "ro") && !value)
|
||||
else if (streq(key, "ro") && !value)
|
||||
arg_root_rw = false;
|
||||
else if (proc_cmdline_key_streq(key, "systemd.image_policy"))
|
||||
return parse_image_policy_argument(optarg, &arg_image_policy);
|
||||
|
||||
else if (proc_cmdline_key_streq(key, "systemd.swap")) {
|
||||
else if (streq(key, "systemd.swap")) {
|
||||
|
||||
r = value ? parse_boolean(value) : 1;
|
||||
if (r < 0)
|
||||
|
|
|
@ -56,7 +56,9 @@ typedef struct EFIHibernateLocation {
|
|||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
if (proc_cmdline_key_streq(key, "resume")) {
|
||||
assert(key);
|
||||
|
||||
if (streq(key, "resume")) {
|
||||
char *s;
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
|
@ -79,7 +81,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
|
||||
arg_resume_offset_set = true;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "resumeflags")) {
|
||||
} else if (streq(key, "resumeflags")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
@ -87,7 +89,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
if (!strextend_with_separator(&arg_resume_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "rootflags")) {
|
||||
} else if (streq(key, "rootflags")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
@ -95,7 +97,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
if (!strextend_with_separator(&arg_root_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "noresume")) {
|
||||
} else if (streq(key, "noresume")) {
|
||||
|
||||
if (value) {
|
||||
log_warning("\"noresume\" kernel command line switch specified with an argument, ignoring.");
|
||||
return 0;
|
||||
|
|
|
@ -512,12 +512,13 @@ static int proc_cmdline_callback(const char *key, const char *value, void *data)
|
|||
struct ProcCmdlineInfo *info = ASSERT_PTR(data);
|
||||
int r;
|
||||
|
||||
assert(key);
|
||||
assert(info->manager);
|
||||
|
||||
/* The kernel command line option names are chosen to be compatible with what various tools already
|
||||
* interpret, for example dracut and SUSE Linux. */
|
||||
|
||||
if (proc_cmdline_key_streq(key, "nameserver")) {
|
||||
if (streq(key, "nameserver")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
@ -534,7 +535,7 @@ static int proc_cmdline_callback(const char *key, const char *value, void *data)
|
|||
|
||||
info->manager->read_resolv_conf = false;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "domain")) {
|
||||
} else if (streq(key, "domain")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
|
|
@ -26,7 +26,9 @@ STATIC_DESTRUCTOR_REGISTER(arg_failure_action, freep);
|
|||
static int parse(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
if (proc_cmdline_key_streq(key, "systemd.run")) {
|
||||
assert(key);
|
||||
|
||||
if (streq(key, "systemd.run")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
|
|
@ -136,7 +136,9 @@ static int create_usr_device(void) {
|
|||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
if (proc_cmdline_key_streq(key, "systemd.verity")) {
|
||||
assert(key);
|
||||
|
||||
if (streq(key, "systemd.verity")) {
|
||||
|
||||
r = value ? parse_boolean(value) : 1;
|
||||
if (r < 0)
|
||||
|
@ -152,7 +154,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
else
|
||||
arg_read_veritytab = r;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "roothash")) {
|
||||
} else if (streq(key, "roothash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
@ -188,7 +190,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "usrhash")) {
|
||||
} else if (streq(key, "usrhash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue