]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: drop de-constifying casts for strv iteration
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 8 May 2022 10:30:51 +0000 (12:30 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 8 May 2022 20:47:50 +0000 (22:47 +0200)
When the the iterator variable is declared automatically, it "inherits" the
const/non-const status from the argument. We don't need to cast a const
table to non-const. If we had a programming error and tried to modify the
string, the compiler could now catch this.

src/core/manager.c
src/shared/bootspec.c
src/shared/conf-parser.c
src/test/test-fs-util.c
src/test/test-sysctl-util.c

index d09d14911c353e39e40b8a274353fac196809a8c..98daa764ebbe16dd9f99897d7a36c7c15796ce4a 100644 (file)
@@ -3655,7 +3655,7 @@ static bool generator_path_any(const char* const* paths) {
 
         /* Optimize by skipping the whole process by not creating output directories
          * if no generators are found. */
-        STRV_FOREACH(path, (char**) paths)
+        STRV_FOREACH(path, paths)
                 if (access(*path, F_OK) == 0)
                         found = true;
                 else if (errno != ENOENT)
index 91cb605fb1ce011aaa81bf4aa9a584d84a096e45..f39d4da6d5e94c3964d7c6fcfc9e39aeb36f72fd 100644 (file)
@@ -960,7 +960,7 @@ int boot_config_augment_from_loader(
                 if (!c)
                         return log_oom();
 
-                STRV_FOREACH_PAIR(a, b, (char**) title_table)
+                STRV_FOREACH_PAIR(a, b, title_table)
                         if (streq(*a, *i)) {
                                 t = strdup(*b);
                                 if (!t)
index a84c47cd26a1d2628b0fec5ca988b09d1b0d48ed..6bd3ab38db8f65e9f4358385a6c0898891cd779d 100644 (file)
@@ -497,7 +497,7 @@ static int config_parse_many_files(
         }
 
         /* First read the first found main config file. */
-        STRV_FOREACH(fn, (char**) conf_files) {
+        STRV_FOREACH(fn, conf_files) {
                 r = config_parse(NULL, *fn, NULL, sections, lookup, table, flags, userdata, &st);
                 if (r < 0)
                         return r;
index f24e97b4ccc956479ee94d21ffa4fc4e499ae931..5d9d99e272a5eabd6376909ec935e5ead0672992 100644 (file)
@@ -712,7 +712,7 @@ TEST(rename_noreplace) {
         j = strjoina(z, table[4]);
         (void) symlink("foobar", j);
 
-        STRV_FOREACH(a, (char**) table) {
+        STRV_FOREACH(a, table) {
                 _cleanup_free_ char *x = NULL, *y = NULL;
 
                 x = strjoin(z, *a);
@@ -723,7 +723,7 @@ TEST(rename_noreplace) {
                         continue;
                 }
 
-                STRV_FOREACH(b, (char**) table) {
+                STRV_FOREACH(b, table) {
                         _cleanup_free_ char *w = NULL;
 
                         w = strjoin(z, *b);
index 02180dc4be8c67b4c6e4bf91be50fd8e4f4cedea..81207f5cfd3c5c15027ee3a168eaab2d0e770977 100644 (file)
@@ -27,7 +27,7 @@ static const char* const cases[] = {
 };
 
 TEST(sysctl_normalize) {
-        STRV_FOREACH_PAIR(s, expected, (const char**) cases) {
+        STRV_FOREACH_PAIR(s, expected, cases) {
                 _cleanup_free_ char *t;
 
                 assert_se(t = strdup(*s));