* [PATCH] OPP: debugfs: Fix warning with W=1 builds
@ 2024-03-04 7:20 Viresh Kumar
2024-03-04 7:42 ` Dhruva Gole
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2024-03-04 7:20 UTC (permalink / raw)
To: Viresh Kumar, Nishanth Menon, Stephen Boyd
Cc: Viresh Kumar, linux-pm, Vincent Guittot, Rafael J. Wysocki,
kernel test robot, linux-kernel
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 another potential issue it by increasing size of the arrays.
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>
---
drivers/opp/debugfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index ec030b19164a..96313aa55db6 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -78,7 +78,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp,
struct opp_table *opp_table,
struct dentry *pdentry)
{
- char name[12];
+ char name[19];
int i;
if (opp_table->clk_count == 1) {
@@ -100,7 +100,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
int i;
for (i = 0; i < opp_table->regulator_count; i++) {
- char name[15];
+ char name[19];
snprintf(name, sizeof(name), "supply-%d", i);
--
2.31.1.272.g89b43f80a514
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] OPP: debugfs: Fix warning with W=1 builds
2024-03-04 7:20 [PATCH] OPP: debugfs: Fix warning with W=1 builds Viresh Kumar
@ 2024-03-04 7:42 ` Dhruva Gole
2024-03-04 10:58 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Dhruva Gole @ 2024-03-04 7:42 UTC (permalink / raw)
To: Viresh Kumar, Viresh Kumar, Nishanth Menon, Stephen Boyd
Cc: linux-pm, Vincent Guittot, Rafael J. Wysocki, kernel test robot,
linux-kernel, Dhruva Gole
Hi Viresh,
On 04/03/24 12:50, Viresh Kumar wrote:
> 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 another potential issue it by increasing size of the arrays.
>
> 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>
> ---
> drivers/opp/debugfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
> index ec030b19164a..96313aa55db6 100644
> --- a/drivers/opp/debugfs.c
> +++ b/drivers/opp/debugfs.c
> @@ -78,7 +78,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp,
> struct opp_table *opp_table,
> struct dentry *pdentry)
> {
> - char name[12];
> + char name[19];
I'd rather we use malloc or else change the limits of the
"rate_hz_%d" to "rate_hz_%4d" or how many ever digits makes sense.
[...]
--
Thanks and Regards,
Dhruva Gole
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] OPP: debugfs: Fix warning with W=1 builds
2024-03-04 7:42 ` Dhruva Gole
@ 2024-03-04 10:58 ` Viresh Kumar
0 siblings, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2024-03-04 10:58 UTC (permalink / raw)
To: Dhruva Gole
Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, linux-pm,
Vincent Guittot, Rafael J. Wysocki, kernel test robot,
linux-kernel
On 04-03-24, 13:12, Dhruva Gole wrote:
> I'd rather we use malloc
The problem is that we don't know the length of the string here and we
don't want to hardcode the number of clks, regulators, etc.
> or else change the limits of the
> "rate_hz_%d" to "rate_hz_%4d" or how many ever digits makes sense.
That will not work I am afraid. This works as you intend to for %s,
but not for %d. With %Nd, N only signifies the minimum space the value
will take.
Let me make it better anyway, will try something.
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-04 10:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 7:20 [PATCH] OPP: debugfs: Fix warning with W=1 builds Viresh Kumar
2024-03-04 7:42 ` Dhruva Gole
2024-03-04 10:58 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®