* [PATCH 1/2] vsprintf: fix missing break when printing %pJP
@ 2025-03-25 15:53 Jules Maselbas
2025-03-25 15:53 ` [PATCH 2/2] vsprintf: add explicit fallthrough Jules Maselbas
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jules Maselbas @ 2025-03-25 15:53 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
When the format `%pJP` was introduced the new switch case didn't had a
break at the end, it was last case in the switch. However subsequent
commit didn't add a break either, creating a potential fallthrough.
Add the missing break.
Fixes: 107eeef8f2 ("vsprintf: add support for printing MAC addresses")
Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
lib/vsprintf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index f553662ce8..0656ba3620 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -561,6 +561,7 @@ static char *pointer(const char *fmt, char *buf, const char *end, const void *pt
case 'J':
if (fmt[1] == 'P' && IS_ENABLED(CONFIG_JSMN))
return jsonpath_string(buf, end, ptr, field_width, precision, flags, fmt);
+ break;
case 'M':
/* Colon separated: 00:01:02:03:04:05 */
return mac_address_string(buf, end, ptr, field_width, precision, flags, fmt);
--
2.48.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] vsprintf: add explicit fallthrough
2025-03-25 15:53 [PATCH 1/2] vsprintf: fix missing break when printing %pJP Jules Maselbas
@ 2025-03-25 15:53 ` Jules Maselbas
2025-03-25 16:58 ` [PATCH 1/2] vsprintf: fix missing break when printing %pJP Ahmad Fatoum
2025-03-27 7:38 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Jules Maselbas @ 2025-03-25 15:53 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
lib/vsprintf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 0656ba3620..32429dd76c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -775,6 +775,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
case 'x':
flags |= SMALL;
+ fallthrough;
case 'X':
base = 16;
break;
@@ -782,6 +783,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
case 'd':
case 'i':
flags |= SIGN;
+ fallthrough;
case 'u':
break;
--
2.48.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] vsprintf: fix missing break when printing %pJP
2025-03-25 15:53 [PATCH 1/2] vsprintf: fix missing break when printing %pJP Jules Maselbas
2025-03-25 15:53 ` [PATCH 2/2] vsprintf: add explicit fallthrough Jules Maselbas
@ 2025-03-25 16:58 ` Ahmad Fatoum
2025-03-27 7:38 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2025-03-25 16:58 UTC (permalink / raw)
To: Jules Maselbas, barebox
Hello Jules,
On 3/25/25 16:53, Jules Maselbas wrote:
> When the format `%pJP` was introduced the new switch case didn't had a
> break at the end, it was last case in the switch. However subsequent
> commit didn't add a break either, creating a potential fallthrough.
> Add the missing break.
>
> Fixes: 107eeef8f2 ("vsprintf: add support for printing MAC addresses")
> Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
Ouch, Good catch.
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Thanks,
Ahmad
> ---
> lib/vsprintf.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index f553662ce8..0656ba3620 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -561,6 +561,7 @@ static char *pointer(const char *fmt, char *buf, const char *end, const void *pt
> case 'J':
> if (fmt[1] == 'P' && IS_ENABLED(CONFIG_JSMN))
> return jsonpath_string(buf, end, ptr, field_width, precision, flags, fmt);
> + break;
> case 'M':
> /* Colon separated: 00:01:02:03:04:05 */
> return mac_address_string(buf, end, ptr, field_width, precision, flags, fmt);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] vsprintf: fix missing break when printing %pJP
2025-03-25 15:53 [PATCH 1/2] vsprintf: fix missing break when printing %pJP Jules Maselbas
2025-03-25 15:53 ` [PATCH 2/2] vsprintf: add explicit fallthrough Jules Maselbas
2025-03-25 16:58 ` [PATCH 1/2] vsprintf: fix missing break when printing %pJP Ahmad Fatoum
@ 2025-03-27 7:38 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2025-03-27 7:38 UTC (permalink / raw)
To: barebox, Jules Maselbas
On Tue, 25 Mar 2025 16:53:26 +0100, Jules Maselbas wrote:
> When the format `%pJP` was introduced the new switch case didn't had a
> break at the end, it was last case in the switch. However subsequent
> commit didn't add a break either, creating a potential fallthrough.
> Add the missing break.
>
>
Applied, thanks!
[1/2] vsprintf: fix missing break when printing %pJP
https://git.pengutronix.de/cgit/barebox/commit/?id=fe9805bfe283 (link may not be stable)
[2/2] vsprintf: add explicit fallthrough
https://git.pengutronix.de/cgit/barebox/commit/?id=b2be41d98bbe (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-27 7:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-25 15:53 [PATCH 1/2] vsprintf: fix missing break when printing %pJP Jules Maselbas
2025-03-25 15:53 ` [PATCH 2/2] vsprintf: add explicit fallthrough Jules Maselbas
2025-03-25 16:58 ` [PATCH 1/2] vsprintf: fix missing break when printing %pJP Ahmad Fatoum
2025-03-27 7:38 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox