From: Heiko Carstens <hca@linux.ibm.com>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] initrd: Fix unused variable warning in rd_load_image() on s390
Date: Wed, 10 Sep 2025 11:52:37 +0200 [thread overview]
Message-ID: <20250910095237.9573B41-hca@linux.ibm.com> (raw)
In-Reply-To: <20250908121303.180886-2-thorsten.blum@linux.dev>
On Mon, Sep 08, 2025 at 02:13:04PM +0200, Thorsten Blum wrote:
> The local variable 'rotate' is not used on s390, and 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.
>
> Fix this by declaring and using 'rotate' only when CONFIG_S390 is not
> defined.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> init/do_mounts_rd.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
> index ac021ae6e6fa..cbc4c496cb5f 100644
> --- a/init/do_mounts_rd.c
> +++ b/init/do_mounts_rd.c
> @@ -189,9 +189,9 @@ int __init rd_load_image(char *from)
> unsigned long rd_blocks, devblocks;
> int nblocks, i;
> char *buf = NULL;
> - unsigned short rotate = 0;
> decompress_fn decompressor = NULL;
> #if !defined(CONFIG_S390)
> + unsigned short rotate = 0;
> char rotator[4] = { '|' , '/' , '-' , '\\' };
> #endif
>
> @@ -249,7 +249,9 @@ int __init rd_load_image(char *from)
> for (i = 0; i < nblocks; i++) {
> if (i && (i % devblocks == 0)) {
> pr_cont("done disk #1.\n");
> +#if !defined(CONFIG_S390)
> rotate = 0;
> +#endif
Instead of adding even more ifdefs, wouldn't it make more sense to get
rid of them and leave it up to the compiler to optimize unused stuff
away? Something like this instead:
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index ac021ae6e6fa..0cc9caf2411d 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -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,11 @@ 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)) {
- pr_cont("%c\b", rotator[rotate & 0x3]);
+ if (!IS_ENABLED(CONFIG_S390))
+ pr_cont("%c\b", rotator[rotate & 0x3]);
rotate++;
}
-#endif
}
pr_cont("done.\n");
next prev parent reply other threads:[~2025-09-10 9:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 12:13 [PATCH] initrd: Fix unused variable warning in rd_load_image() on s390 Thorsten Blum
2025-09-10 9:52 ` Heiko Carstens [this message]
2025-09-10 14:34 ` Thorsten Blum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250910095237.9573B41-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=thorsten.blum@linux.dev \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox