* [PATCH] perf hwmon_pmu: Fix uninitialized variable warning
@ 2025-10-22 10:38 Michal Suchanek
2025-10-23 21:50 ` Namhyung Kim
2025-10-30 3:46 ` Namhyung Kim
0 siblings, 2 replies; 3+ messages in thread
From: Michal Suchanek @ 2025-10-22 10:38 UTC (permalink / raw)
To: linux-perf-users
Cc: Michal Suchanek, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Thomas Richter, linux-kernel, Tony Jones
The line_len is only set on success. Check the return value instead.
Fixes: 53cc0b351ec9 ("perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
tools/perf/util/hwmon_pmu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/perf/util/hwmon_pmu.c b/tools/perf/util/hwmon_pmu.c
index 416dfea9ffff..5c27256a220a 100644
--- a/tools/perf/util/hwmon_pmu.c
+++ b/tools/perf/util/hwmon_pmu.c
@@ -742,8 +742,7 @@ int perf_pmus__read_hwmon_pmus(struct list_head *pmus)
continue;
}
io__init(&io, name_fd, buf2, sizeof(buf2));
- io__getline(&io, &line, &line_len);
- if (line_len > 0 && line[line_len - 1] == '\n')
+ if (io__getline(&io, &line, &line_len) > 0 && line[line_len - 1] == '\n')
line[line_len - 1] = '\0';
hwmon_pmu__new(pmus, buf, class_hwmon_ent->d_name, line);
close(name_fd);
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf hwmon_pmu: Fix uninitialized variable warning
2025-10-22 10:38 [PATCH] perf hwmon_pmu: Fix uninitialized variable warning Michal Suchanek
@ 2025-10-23 21:50 ` Namhyung Kim
2025-10-30 3:46 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-10-23 21:50 UTC (permalink / raw)
To: Michal Suchanek
Cc: linux-perf-users, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Ian Rogers, Adrian Hunter, Thomas Richter,
linux-kernel, Tony Jones
Hello,
On Wed, Oct 22, 2025 at 12:38:35PM +0200, Michal Suchanek wrote:
> The line_len is only set on success. Check the return value instead.
Can you please share the actual warning messages from the compiler?
Thanks,
Namhyung
>
> Fixes: 53cc0b351ec9 ("perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs")
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
> tools/perf/util/hwmon_pmu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/hwmon_pmu.c b/tools/perf/util/hwmon_pmu.c
> index 416dfea9ffff..5c27256a220a 100644
> --- a/tools/perf/util/hwmon_pmu.c
> +++ b/tools/perf/util/hwmon_pmu.c
> @@ -742,8 +742,7 @@ int perf_pmus__read_hwmon_pmus(struct list_head *pmus)
> continue;
> }
> io__init(&io, name_fd, buf2, sizeof(buf2));
> - io__getline(&io, &line, &line_len);
> - if (line_len > 0 && line[line_len - 1] == '\n')
> + if (io__getline(&io, &line, &line_len) > 0 && line[line_len - 1] == '\n')
> line[line_len - 1] = '\0';
> hwmon_pmu__new(pmus, buf, class_hwmon_ent->d_name, line);
> close(name_fd);
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf hwmon_pmu: Fix uninitialized variable warning
2025-10-22 10:38 [PATCH] perf hwmon_pmu: Fix uninitialized variable warning Michal Suchanek
2025-10-23 21:50 ` Namhyung Kim
@ 2025-10-30 3:46 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-10-30 3:46 UTC (permalink / raw)
To: linux-perf-users, Michal Suchanek
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Thomas Richter, linux-kernel, Tony Jones
On Wed, 22 Oct 2025 12:38:35 +0200, Michal Suchanek wrote:
> The line_len is only set on success. Check the return value instead.
>
>
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-30 3:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 10:38 [PATCH] perf hwmon_pmu: Fix uninitialized variable warning Michal Suchanek
2025-10-23 21:50 ` Namhyung Kim
2025-10-30 3:46 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox