Skip to contentSkip to conversation

tools/perf/util/machine: Return NULL instead of null-terminating

PATCH Superseded Donald Yandt 1 participant 1 message May 21, 2019 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/perf/util/machine: Return NULL instead of null-terminating

Return NULL instead of null-terminating version char array when fgets fails due to end-of-file or error.

---
 tools/perf/util/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +2 -2
index 28a9541c4..6fd877220 100644
@@ -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