]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wise: drop unnecessary use of proc_cmdline_key_streq() 28727/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Aug 2023 17:44:52 +0000 (02:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Aug 2023 18:16:31 +0000 (03:16 +0900)
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.

src/fstab-generator/fstab-generator.c
src/gpt-auto-generator/gpt-auto-generator.c
src/hibernate-resume/hibernate-resume-generator.c
src/resolve/resolved-conf.c
src/run-generator/run-generator.c
src/veritysetup/veritysetup-generator.c

index 041789673ff2b14f800aa3cd9368a2e2a7a8eeb6..c88f5d4b47d1ff090543286119fa7cfa2b74c081 100644 (file)
@@ -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 */
index fed670e7f4ab5fb774e9ec7a74beda7b13279df6..ec047a14b52426602492d3844d35c30f2d20534c 100644 (file)
@@ -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)
index fcd288923872b021d9264ae608ec6c0cdc31c1b4..8b83ad6bdb39e14f98eb82fc29cd765016aa0658 100644 (file)
@@ -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;
index 94a579275fdefc71bacd18c06e687a459aade89a..2f08ed0fe67dfd87200d18a803e8b1579fc2fd87 100644 (file)
@@ -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;
index e3fb7f24fe6100ac7e07de13fbe38595c61ca9cd..dda7c36159ec3c055a1c3643ad70724432640db0 100644 (file)
@@ -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;
index 303e0ced6d7512230479e08834e187acfd491b52..59ff4cd7a52741bd1c793ee7738a5bb5b6ed6c11 100644 (file)
@@ -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;