* [PATCH] lib/vsprintf: use bool for local decode variable
@ 2026-04-07 18:18 Thorsten Blum
2026-04-07 19:29 ` David Laight
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-04-07 18:18 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Steven Rostedt, Andy Shevchenko,
Rasmus Villemoes, Sergey Senozhatsky
Cc: Thorsten Blum, linux-kernel
The local variable 'decode' is only used as a boolean value - change its
data type from int to bool accordingly.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
lib/vsprintf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 800b8ac49f53..9f359b31c8d1 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1107,7 +1107,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)];
char *p = sym, *pend = sym + sizeof(sym);
- int decode = (fmt[0] == 'R') ? 1 : 0;
+ bool decode = fmt[0] == 'R';
const struct printf_spec *specp;
if (check_pointer(&buf, end, res, spec))
@@ -1132,7 +1132,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
} else {
p = string_nocheck(p, pend, "??? ", str_spec);
specp = &mem_spec;
- decode = 0;
+ decode = false;
}
if (decode && res->flags & IORESOURCE_UNSET) {
p = string_nocheck(p, pend, "size ", str_spec);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] lib/vsprintf: use bool for local decode variable
2026-04-07 18:18 [PATCH] lib/vsprintf: use bool for local decode variable Thorsten Blum
@ 2026-04-07 19:29 ` David Laight
2026-04-08 7:53 ` Petr Mladek
2026-04-14 14:25 ` Petr Mladek
2 siblings, 0 replies; 6+ messages in thread
From: David Laight @ 2026-04-07 19:29 UTC (permalink / raw)
To: Thorsten Blum
Cc: Andrew Morton, Petr Mladek, Steven Rostedt, Andy Shevchenko,
Rasmus Villemoes, Sergey Senozhatsky, linux-kernel
On Tue, 7 Apr 2026 20:18:36 +0200
Thorsten Blum <thorsten.blum@linux.dev> wrote:
> The local variable 'decode' is only used as a boolean value - change its
> data type from int to bool accordingly.
Hopefully the compiler actually does:
int decode = fmt[0];
and then compares against 'R' later on.
But this change ought to make absolutely no difference to the code.
David
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> lib/vsprintf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 800b8ac49f53..9f359b31c8d1 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1107,7 +1107,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
> 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)];
>
> char *p = sym, *pend = sym + sizeof(sym);
> - int decode = (fmt[0] == 'R') ? 1 : 0;
> + bool decode = fmt[0] == 'R';
> const struct printf_spec *specp;
>
> if (check_pointer(&buf, end, res, spec))
> @@ -1132,7 +1132,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
> } else {
> p = string_nocheck(p, pend, "??? ", str_spec);
> specp = &mem_spec;
> - decode = 0;
> + decode = false;
> }
> if (decode && res->flags & IORESOURCE_UNSET) {
> p = string_nocheck(p, pend, "size ", str_spec);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lib/vsprintf: use bool for local decode variable
2026-04-07 18:18 [PATCH] lib/vsprintf: use bool for local decode variable Thorsten Blum
2026-04-07 19:29 ` David Laight
@ 2026-04-08 7:53 ` Petr Mladek
2026-04-08 13:18 ` Andy Shevchenko
2026-04-14 14:25 ` Petr Mladek
2 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2026-04-08 7:53 UTC (permalink / raw)
To: Thorsten Blum
Cc: Andrew Morton, Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
Sergey Senozhatsky, linux-kernel
On Tue 2026-04-07 20:18:36, Thorsten Blum wrote:
> The local variable 'decode' is only used as a boolean value - change its
> data type from int to bool accordingly.
>
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1107,7 +1107,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
> 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)];
>
> char *p = sym, *pend = sym + sizeof(sym);
> - int decode = (fmt[0] == 'R') ? 1 : 0;
> + bool decode = fmt[0] == 'R';
> const struct printf_spec *specp;
>
> if (check_pointer(&buf, end, res, spec))
> @@ -1132,7 +1132,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
> } else {
> p = string_nocheck(p, pend, "??? ", str_spec);
> specp = &mem_spec;
> - decode = 0;
> + decode = false;
> }
> if (decode && res->flags & IORESOURCE_UNSET) {
> p = string_nocheck(p, pend, "size ", str_spec);
I have mixed feeling about this patch. I agree that it might slightly
improve code readability. But cosmetic changes are usually about
personal preferences and often just pollute code history.
IMHO, this is really just about "code readability" vs "code history
pollution" problem. I believe that compilers would handle both variants
the same way.
As I said, I agree that this this slightly improves the code
readability and it is trivial. So I am going to wait few more
days and take this patch unless there is a strong push back
from others.
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lib/vsprintf: use bool for local decode variable
2026-04-08 7:53 ` Petr Mladek
@ 2026-04-08 13:18 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-04-08 13:18 UTC (permalink / raw)
To: Petr Mladek
Cc: Thorsten Blum, Andrew Morton, Steven Rostedt, Rasmus Villemoes,
Sergey Senozhatsky, linux-kernel
On Wed, Apr 08, 2026 at 09:53:35AM +0200, Petr Mladek wrote:
> On Tue 2026-04-07 20:18:36, Thorsten Blum wrote:
...
> I have mixed feeling about this patch
Same here.
> I agree that it might slightly
> improve code readability. But cosmetic changes are usually about
> personal preferences and often just pollute code history.
>
> IMHO, this is really just about "code readability" vs "code history
> pollution" problem. I believe that compilers would handle both variants
> the same way.
>
> As I said, I agree that this this slightly improves the code
> readability and it is trivial. So I am going to wait few more
> days and take this patch unless there is a strong push back
> from others.
Up to you, no pushback from me, and no tag as well. Personally
I consider it's a churn, but we have tons of a such in the kernel
(I mean int as boolean cases).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lib/vsprintf: use bool for local decode variable
2026-04-07 18:18 [PATCH] lib/vsprintf: use bool for local decode variable Thorsten Blum
2026-04-07 19:29 ` David Laight
2026-04-08 7:53 ` Petr Mladek
@ 2026-04-14 14:25 ` Petr Mladek
2026-04-14 15:36 ` Thorsten Blum
2 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2026-04-14 14:25 UTC (permalink / raw)
To: Thorsten Blum
Cc: Andrew Morton, Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
Sergey Senozhatsky, linux-kernel
On Tue 2026-04-07 20:18:36, Thorsten Blum wrote:
> The local variable 'decode' is only used as a boolean value - change its
> data type from int to bool accordingly.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
JFYI, the patch has been comitted into printk/linux.git,
branch for-7.1.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lib/vsprintf: use bool for local decode variable
2026-04-14 14:25 ` Petr Mladek
@ 2026-04-14 15:36 ` Thorsten Blum
0 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-04-14 15:36 UTC (permalink / raw)
To: Petr Mladek
Cc: Andrew Morton, Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
Sergey Senozhatsky, linux-kernel
On Tue, Apr 14, 2026 at 04:25:21PM +0200, Petr Mladek wrote:
> On Tue 2026-04-07 20:18:36, Thorsten Blum wrote:
> > The local variable 'decode' is only used as a boolean value - change its
> > data type from int to bool accordingly.
> >
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>
> JFYI, the patch has been comitted into printk/linux.git,
> branch for-7.1.
Thank you!
> Best Regards,
> Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-14 15:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 18:18 [PATCH] lib/vsprintf: use bool for local decode variable Thorsten Blum
2026-04-07 19:29 ` David Laight
2026-04-08 7:53 ` Petr Mladek
2026-04-08 13:18 ` Andy Shevchenko
2026-04-14 14:25 ` Petr Mladek
2026-04-14 15:36 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox