Skip to content

Commit 2fee899

Browse files
hramrachnamhyung
authored andcommitted
perf hwmon_pmu: Fix uninitialized variable warning
The line_len is only set on success. Check the return value instead. util/hwmon_pmu.c: In function ‘perf_pmus__read_hwmon_pmus’: util/hwmon_pmu.c:742:20: warning: ‘line_len’ may be used uninitialized [-Wmaybe-uninitialized] 742 | if (line_len > 0 && line[line_len - 1] == '\n') | ^ util/hwmon_pmu.c:719:24: note: ‘line_len’ was declared here 719 | size_t line_len; Fixes: 53cc0b3 ("perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs") Signed-off-by: Michal Suchanek <msuchanek@suse.de> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent ab29ff9 commit 2fee899

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tools/perf/util/hwmon_pmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,7 @@ int perf_pmus__read_hwmon_pmus(struct list_head *pmus)
742742
continue;
743743
}
744744
io__init(&io, name_fd, buf2, sizeof(buf2));
745-
io__getline(&io, &line, &line_len);
746-
if (line_len > 0 && line[line_len - 1] == '\n')
745+
if (io__getline(&io, &line, &line_len) > 0 && line[line_len - 1] == '\n')
747746
line[line_len - 1] = '\0';
748747
hwmon_pmu__new(pmus, buf, class_hwmon_ent->d_name, line);
749748
close(name_fd);

0 commit comments

Comments
 (0)