Skip to content

Commit a2fdc5d

Browse files
arndbgregkh
authored andcommitted
clk: qoriq: avoid format string warning
[ Upstream commit 096abbb ] 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: 0dfc86b ("clk: qoriq: Move chip-specific knowledge into driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Kees Cook <kees@kernel.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1b97740 commit a2fdc5d

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/clk/clk-qoriq.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -906,22 +906,23 @@ static const struct clockgen_pll_div *get_pll_div(struct clockgen *cg,
906906
return &cg->pll[pll].div[div];
907907
}
908908

909-
static struct clk * __init create_mux_common(struct clockgen *cg,
910-
struct mux_hwclock *hwc,
911-
const struct clk_ops *ops,
912-
unsigned long min_rate,
913-
unsigned long max_rate,
914-
unsigned long pct80_rate,
915-
const char *fmt, int idx)
909+
static struct clk * __init __printf(7, 8)
910+
create_mux_common(struct clockgen *cg, struct mux_hwclock *hwc,
911+
const struct clk_ops *ops, unsigned long min_rate,
912+
unsigned long max_rate, unsigned long pct80_rate,
913+
const char *fmt, ...)
916914
{
917915
struct clk_init_data init = {};
918916
struct clk *clk;
919917
const struct clockgen_pll_div *div;
920918
const char *parent_names[NUM_MUX_PARENTS];
921919
char name[32];
922920
int i, j;
921+
va_list args;
923922

924-
snprintf(name, sizeof(name), fmt, idx);
923+
va_start(args, fmt);
924+
vsnprintf(name, sizeof(name), fmt, args);
925+
va_end(args);
925926

926927
for (i = 0, j = 0; i < NUM_MUX_PARENTS; i++) {
927928
unsigned long rate;

0 commit comments

Comments
 (0)