clk: cdce925: Size the PLL child name buffer for any int

The PLL child node name is built from "PLL%d" in a 6 byte stack buffer.
The PLL index is bounded by the chip's num_plls, at most 4, but GCC
cannot see that bound and, with W=1, warns that the formatted string
may not fit.

Make the buffer large enough to hold any int and use snprintf() with
sizeof() so the size stays tied to the declaration.

Fixes: 19fbbbbcd3 ("Add TI CDCE925 I2C controlled clock synthesizer driver")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://patch.msgid.link/20261014-cdce925-truncate-child-name-v1-1-00136be00c49@baylibre.com
Signed-off-by: Brian Masney <bmasney@redhat.com>
This commit is contained in:
Jerome Brunet 2026-10-14 18:11:53 +02:00 committed by Brian Masney
parent 40e5d379cc
commit e9e6b4dc30

View File

@ -625,7 +625,12 @@ static int cdce925_probe(struct i2c_client *client)
int i;
int err;
struct device_node *np_output;
char child_name[6];
/*
* The PLL number isn't a compile time constant so GCC can't infer
* the number. Make the stack buffer large enough to hold any int
* so Wformat-truncation does not complain.
*/
char child_name[15];
struct regmap_config config = {
.name = "configuration0",
.reg_bits = 8,
@ -697,7 +702,7 @@ static int cdce925_probe(struct i2c_client *client)
dev_err(&client->dev, "Failed register PLL %d\n", i);
goto error;
}
sprintf(child_name, "PLL%d", i+1);
snprintf(child_name, sizeof(child_name), "PLL%d", i + 1);
np_output = of_get_child_by_name(node, child_name);
if (!np_output)
continue;