Skip to content

Commit 992e883

Browse files
committed
OPP: debugfs: Fix warning with W=1 builds
We currently get the following warning: debugfs.c:105:54: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=] snprintf(name, sizeof(name), "supply-%d", i); ^~ debugfs.c:105:46: note: directive argument in the range [-2147483644, 2147483646] snprintf(name, sizeof(name), "supply-%d", i); ^~~~~~~~~~~ debugfs.c:105:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15 snprintf(name, sizeof(name), "supply-%d", i); Fix this and other potential issues it by allocating larger arrays. Use the exact string format to allocate the arrays without getting into these issues again. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202402141313.81ltVF5g-lkp@intel.com/ Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Dhruva Gole <d-gole@ti.com>
1 parent 838a477 commit 992e883

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/opp/debugfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ static void opp_debug_create_bw(struct dev_pm_opp *opp,
5656
struct dentry *pdentry)
5757
{
5858
struct dentry *d;
59-
char name[20];
59+
char name[] = "icc-path-XXXXXXXXXXX"; /* Integers can take 11 chars max */
6060
int i;
6161

6262
for (i = 0; i < opp_table->path_count; i++) {
63-
snprintf(name, sizeof(name), "icc-path-%.1d", i);
63+
snprintf(name, sizeof(name), "icc-path-%d", i);
6464

6565
/* Create per-path directory */
6666
d = debugfs_create_dir(name, pdentry);
@@ -78,7 +78,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp,
7878
struct opp_table *opp_table,
7979
struct dentry *pdentry)
8080
{
81-
char name[12];
81+
char name[] = "rate_hz_XXXXXXXXXXX"; /* Integers can take 11 chars max */
8282
int i;
8383

8484
if (opp_table->clk_count == 1) {
@@ -100,7 +100,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
100100
int i;
101101

102102
for (i = 0; i < opp_table->regulator_count; i++) {
103-
char name[15];
103+
char name[] = "supply-XXXXXXXXXXX"; /* Integers can take 11 chars max */
104104

105105
snprintf(name, sizeof(name), "supply-%d", i);
106106

0 commit comments

Comments
 (0)