The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] initrd: Fix unused variable warning in rd_load_image() on s390
@ 2025-09-11  9:49 Thorsten Blum
  2025-09-15 12:27 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-09-11  9:49 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jan Kara
  Cc: linux-s390, Heiko Carstens, Thorsten Blum, linux-fsdevel,
	linux-kernel

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>
---
Changes in v2:
- Use IS_ENABLED(CONFIG_S390) instead of the preprocessor directives as
  suggested by Heiko Carstens <hca@linux.ibm.com>
- Link to v1: https://lore.kernel.org/lkml/20250908121303.180886-2-thorsten.blum@linux.dev/
---
 init/do_mounts_rd.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index ac021ae6e6fa..3cbdf43a42df 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,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");
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] initrd: Fix unused variable warning in rd_load_image() on s390
  2025-09-11  9:49 [PATCH v2] initrd: Fix unused variable warning in rd_load_image() on s390 Thorsten Blum
@ 2025-09-15 12:27 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2025-09-15 12:27 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Christian Brauner, linux-s390, Heiko Carstens, linux-fsdevel,
	linux-kernel, Alexander Viro, Jan Kara

On Thu, 11 Sep 2025 11:49:08 +0200, Thorsten Blum wrote:
> 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.
> 
> [...]

Applied to the vfs-6.18.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.18.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.18.misc

[1/1] initrd: Fix unused variable warning in rd_load_image() on s390
      https://git.kernel.org/vfs/vfs/c/7c1d7695216f

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-15 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  9:49 [PATCH v2] initrd: Fix unused variable warning in rd_load_image() on s390 Thorsten Blum
2025-09-15 12:27 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox