* [PATCH] clk: qoriq: avoid formwat string warning
@ 2026-03-20 15:18 Arnd Bergmann
2026-03-20 18:00 ` Kees Cook
2026-03-24 0:16 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2026-03-20 15:18 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Nathan Chancellor, Scott Wood
Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
Kees Cook, linux-clk, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
clang-22 warns about the use of non-variadic format arguments passed into
snprintf():
drivers/clk/clk-qoriq.c:925:39: error: diagnostic behavior may be improved by adding the
'format(printf, 7, 8)' attribute to the declaration of 'create_mux_common' [-Werror,-Wmissing-format-attribute]
910 | static struct clk * __init create_mux_common(struct clockgen *cg,
| __attribute__((format(printf, 7, 8)))
911 | struct mux_hwclock *hwc,
912 | const struct clk_ops *ops,
913 | unsigned long min_rate,
914 | unsigned long max_rate,
915 | unsigned long pct80_rate,
916 | const char *fmt, int idx)
917 | {
918 | struct clk_init_data init = {};
919 | struct clk *clk;
920 | const struct clockgen_pll_div *div;
921 | const char *parent_names[NUM_MUX_PARENTS];
922 | char name[32];
923 | int i, j;
924 |
925 | snprintf(name, sizeof(name), fmt, idx);
| ^
drivers/clk/clk-qoriq.c:910:28: note: 'create_mux_common' declared here
910 | static struct clk * __init create_mux_common(struct clockgen *cg,
Rework this to pass the 'int idx' as a varargs argument, allowing the
format string to be verified at the caller location.
Fixes: 0dfc86b3173f ("clk: qoriq: Move chip-specific knowledge into driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/clk/clk-qoriq.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index f05631e55310..2524c5c0eb46 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -907,13 +907,11 @@ static const struct clockgen_pll_div *get_pll_div(struct clockgen *cg,
return &cg->pll[pll].div[div];
}
-static struct clk * __init create_mux_common(struct clockgen *cg,
- struct mux_hwclock *hwc,
- const struct clk_ops *ops,
- unsigned long min_rate,
- unsigned long max_rate,
- unsigned long pct80_rate,
- const char *fmt, int idx)
+static struct clk * __init __printf(7, 8)
+create_mux_common(struct clockgen *cg, struct mux_hwclock *hwc,
+ const struct clk_ops *ops, unsigned long min_rate,
+ unsigned long max_rate, unsigned long pct80_rate,
+ const char *fmt, ...)
{
struct clk_init_data init = {};
struct clk *clk;
@@ -921,8 +919,11 @@ static struct clk * __init create_mux_common(struct clockgen *cg,
const char *parent_names[NUM_MUX_PARENTS];
char name[32];
int i, j;
+ va_list args;
- snprintf(name, sizeof(name), fmt, idx);
+ va_start(args, fmt);
+ vsnprintf(name, sizeof(name), fmt, args);
+ va_end(args);
for (i = 0, j = 0; i < NUM_MUX_PARENTS; i++) {
unsigned long rate;
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] clk: qoriq: avoid formwat string warning
2026-03-20 15:18 [PATCH] clk: qoriq: avoid formwat string warning Arnd Bergmann
@ 2026-03-20 18:00 ` Kees Cook
2026-03-24 0:16 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2026-03-20 18:00 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Michael Turquette, Stephen Boyd, Nathan Chancellor, Scott Wood,
Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-clk, linux-kernel, llvm
Nit: $subject typo "formwat" -> "format", but otherwise looks good.
On Fri, Mar 20, 2026 at 04:18:49PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-22 warns about the use of non-variadic format arguments passed into
> snprintf():
>
> drivers/clk/clk-qoriq.c:925:39: error: diagnostic behavior may be improved by adding the
> 'format(printf, 7, 8)' attribute to the declaration of 'create_mux_common' [-Werror,-Wmissing-format-attribute]
> 910 | static struct clk * __init create_mux_common(struct clockgen *cg,
> | __attribute__((format(printf, 7, 8)))
> 911 | struct mux_hwclock *hwc,
> 912 | const struct clk_ops *ops,
> 913 | unsigned long min_rate,
> 914 | unsigned long max_rate,
> 915 | unsigned long pct80_rate,
> 916 | const char *fmt, int idx)
> 917 | {
> 918 | struct clk_init_data init = {};
> 919 | struct clk *clk;
> 920 | const struct clockgen_pll_div *div;
> 921 | const char *parent_names[NUM_MUX_PARENTS];
> 922 | char name[32];
> 923 | int i, j;
> 924 |
> 925 | snprintf(name, sizeof(name), fmt, idx);
> | ^
> drivers/clk/clk-qoriq.c:910:28: note: 'create_mux_common' declared here
> 910 | static struct clk * __init create_mux_common(struct clockgen *cg,
>
> Rework this to pass the 'int idx' as a varargs argument, allowing the
> format string to be verified at the caller location.
>
> Fixes: 0dfc86b3173f ("clk: qoriq: Move chip-specific knowledge into driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] clk: qoriq: avoid formwat string warning
2026-03-20 15:18 [PATCH] clk: qoriq: avoid formwat string warning Arnd Bergmann
2026-03-20 18:00 ` Kees Cook
@ 2026-03-24 0:16 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2026-03-24 0:16 UTC (permalink / raw)
To: Arnd Bergmann, Michael Turquette, Nathan Chancellor, Scott Wood
Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
Kees Cook, linux-clk, linux-kernel, llvm
Quoting Arnd Bergmann (2026-03-20 08:18:49)
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-22 warns about the use of non-variadic format arguments passed into
> snprintf():
>
> drivers/clk/clk-qoriq.c:925:39: error: diagnostic behavior may be improved by adding the
> 'format(printf, 7, 8)' attribute to the declaration of 'create_mux_common' [-Werror,-Wmissing-format-attribute]
> 910 | static struct clk * __init create_mux_common(struct clockgen *cg,
> | __attribute__((format(printf, 7, 8)))
> 911 | struct mux_hwclock *hwc,
> 912 | const struct clk_ops *ops,
> 913 | unsigned long min_rate,
> 914 | unsigned long max_rate,
> 915 | unsigned long pct80_rate,
> 916 | const char *fmt, int idx)
> 917 | {
> 918 | struct clk_init_data init = {};
> 919 | struct clk *clk;
> 920 | const struct clockgen_pll_div *div;
> 921 | const char *parent_names[NUM_MUX_PARENTS];
> 922 | char name[32];
> 923 | int i, j;
> 924 |
> 925 | snprintf(name, sizeof(name), fmt, idx);
> | ^
> drivers/clk/clk-qoriq.c:910:28: note: 'create_mux_common' declared here
> 910 | static struct clk * __init create_mux_common(struct clockgen *cg,
>
> Rework this to pass the 'int idx' as a varargs argument, allowing the
> format string to be verified at the caller location.
>
> Fixes: 0dfc86b3173f ("clk: qoriq: Move chip-specific knowledge into driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-24 0:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 15:18 [PATCH] clk: qoriq: avoid formwat string warning Arnd Bergmann
2026-03-20 18:00 ` Kees Cook
2026-03-24 0:16 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox