* [PATCH] initrd: Use str_plural() in rd_load_image()
@ 2025-09-12 7:46 Thorsten Blum
2025-09-12 10:50 ` Jan Kara
2025-09-15 12:47 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-09-12 7:46 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: Thorsten Blum, linux-fsdevel, linux-kernel
Add the local variable 'nr_disks' and replace the manual ternary "s"
pluralization with the standardized str_plural() helper function.
Use pr_notice() instead of printk(KERN_NOTICE) to silence a checkpatch
warning.
No functional changes intended.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
init/do_mounts_rd.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index ac021ae6e6fa..b8fccc7ffb7d 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -7,6 +7,7 @@
#include <uapi/linux/cramfs_fs.h>
#include <linux/initrd.h>
#include <linux/string.h>
+#include <linux/string_choices.h>
#include <linux/slab.h>
#include "do_mounts.h"
@@ -186,7 +187,7 @@ static unsigned long nr_blocks(struct file *file)
int __init rd_load_image(char *from)
{
int res = 0;
- unsigned long rd_blocks, devblocks;
+ unsigned long rd_blocks, devblocks, nr_disks;
int nblocks, i;
char *buf = NULL;
unsigned short rotate = 0;
@@ -244,8 +245,9 @@ int __init rd_load_image(char *from)
goto done;
}
- printk(KERN_NOTICE "RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
- nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : "");
+ nr_disks = (nblocks - 1) / devblocks + 1;
+ pr_notice("RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
+ nblocks, nr_disks, str_plural(nr_disks));
for (i = 0; i < nblocks; i++) {
if (i && (i % devblocks == 0)) {
pr_cont("done disk #1.\n");
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] initrd: Use str_plural() in rd_load_image()
2025-09-12 7:46 [PATCH] initrd: Use str_plural() in rd_load_image() Thorsten Blum
@ 2025-09-12 10:50 ` Jan Kara
2025-09-15 12:47 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2025-09-12 10:50 UTC (permalink / raw)
To: Thorsten Blum
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel,
linux-kernel
On Fri 12-09-25 09:46:52, Thorsten Blum wrote:
> Add the local variable 'nr_disks' and replace the manual ternary "s"
> pluralization with the standardized str_plural() helper function.
>
> Use pr_notice() instead of printk(KERN_NOTICE) to silence a checkpatch
> warning.
>
> No functional changes intended.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> init/do_mounts_rd.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
> index ac021ae6e6fa..b8fccc7ffb7d 100644
> --- a/init/do_mounts_rd.c
> +++ b/init/do_mounts_rd.c
> @@ -7,6 +7,7 @@
> #include <uapi/linux/cramfs_fs.h>
> #include <linux/initrd.h>
> #include <linux/string.h>
> +#include <linux/string_choices.h>
> #include <linux/slab.h>
>
> #include "do_mounts.h"
> @@ -186,7 +187,7 @@ static unsigned long nr_blocks(struct file *file)
> int __init rd_load_image(char *from)
> {
> int res = 0;
> - unsigned long rd_blocks, devblocks;
> + unsigned long rd_blocks, devblocks, nr_disks;
> int nblocks, i;
> char *buf = NULL;
> unsigned short rotate = 0;
> @@ -244,8 +245,9 @@ int __init rd_load_image(char *from)
> goto done;
> }
>
> - printk(KERN_NOTICE "RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
> - nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : "");
> + nr_disks = (nblocks - 1) / devblocks + 1;
> + pr_notice("RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
> + nblocks, nr_disks, str_plural(nr_disks));
> for (i = 0; i < nblocks; i++) {
> if (i && (i % devblocks == 0)) {
> pr_cont("done disk #1.\n");
> --
> 2.51.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] initrd: Use str_plural() in rd_load_image()
2025-09-12 7:46 [PATCH] initrd: Use str_plural() in rd_load_image() Thorsten Blum
2025-09-12 10:50 ` Jan Kara
@ 2025-09-15 12:47 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-09-15 12:47 UTC (permalink / raw)
To: Thorsten Blum
Cc: Christian Brauner, linux-fsdevel, linux-kernel, Alexander Viro,
Jan Kara
On Fri, 12 Sep 2025 09:46:52 +0200, Thorsten Blum wrote:
> Add the local variable 'nr_disks' and replace the manual ternary "s"
> pluralization with the standardized str_plural() helper function.
>
> Use pr_notice() instead of printk(KERN_NOTICE) to silence a checkpatch
> warning.
>
> No functional changes intended.
>
> [...]
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: Use str_plural() in rd_load_image()
https://git.kernel.org/vfs/vfs/c/beb022ef9263
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-15 12:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 7:46 [PATCH] initrd: Use str_plural() in rd_load_image() Thorsten Blum
2025-09-12 10:50 ` Jan Kara
2025-09-15 12:47 ` Christian Brauner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.