* [PATCH perf/core] tools/perf/util/machine: Return NULL instead of null-terminating
@ 2019-05-21 17:54 Donald Yandt
0 siblings, 0 replies; only message in thread
From: Donald Yandt @ 2019-05-21 17:54 UTC (permalink / raw)
To: peterz
Cc: mingo, acme, alexander.shishkin, jolsa, yanmin_zhang,
linux-kernel, Donald Yandt
Return NULL instead of null-terminating version char array when fgets fails due to end-of-file or error.
Signed-off-by: Donald Yandt <donald.yandt@gmail.com>
---
tools/perf/util/machine.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 28a9541c4..6fd877220 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1235,9 +1235,9 @@ static char *get_kernel_version(const char *root_dir)
return NULL;
tmp = fgets(version, sizeof(version), file);
- if (!tmp)
- *version = '\0';
fclose(file);
+ if (!tmp)
+ return NULL;
name = strstr(version, prefix);
if (!name)
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-05-21 17:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 17:54 [PATCH perf/core] tools/perf/util/machine: Return NULL instead of null-terminating Donald Yandt
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).