linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2025-10-30  3:46 UTC | newest]

Thread overview: 5+ 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-23 22:11   ` Tony Jones
2025-10-24  2:10     ` 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;
as well as URLs for NNTP newsgroup(s).