]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
initrd: Fix unused variable warning in rd_load_image() on s390
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 11 Sep 2025 09:49:08 +0000 (11:49 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Sep 2025 12:28:37 +0000 (14:28 +0200)
The local variables 'rotator' and 'rotate' (used for the progress
indicator) aren't used on s390. Building the kernel with W=1 generates
the following warning:

init/do_mounts_rd.c:192:17: warning: variable 'rotate' set but not used [-Wunused-but-set-variable]
 192 |         unsigned short rotate = 0;
     |                        ^
1 warning generated.

Remove the preprocessor directives and use the IS_ENABLED(CONFIG_S390)
macro instead, allowing the compiler to optimize away unused variables
and avoid the warning on s390.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Christian Brauner <brauner@kernel.org>
init/do_mounts_rd.c

index ac021ae6e6fa78c7b7828a78ab2fa3af3611bef3..3cbdf43a42dff551008fdbd4d27178714c6b89f2 100644 (file)
@@ -191,9 +191,7 @@ int __init rd_load_image(char *from)
        char *buf = NULL;
        unsigned short rotate = 0;
        decompress_fn decompressor = NULL;
-#if !defined(CONFIG_S390)
        char rotator[4] = { '|' , '/' , '-' , '\\' };
-#endif
 
        out_file = filp_open("/dev/ram", O_RDWR, 0);
        if (IS_ERR(out_file))
@@ -255,12 +253,10 @@ int __init rd_load_image(char *from)
                }
                kernel_read(in_file, buf, BLOCK_SIZE, &in_pos);
                kernel_write(out_file, buf, BLOCK_SIZE, &out_pos);
-#if !defined(CONFIG_S390)
-               if (!(i % 16)) {
+               if (!IS_ENABLED(CONFIG_S390) && !(i % 16)) {
                        pr_cont("%c\b", rotator[rotate & 0x3]);
                        rotate++;
                }
-#endif
        }
        pr_cont("done.\n");