LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Donald Yandt <donald.yandt@gmail.com>
To: peterz@infradead.org
Cc: mingo@redhat.com, acme@kernel.org,
	alexander.shishkin@linux.intel.com, jolsa@redhat.com,
	yanmin_zhang@linux.intel.com, linux-kernel@vger.kernel.org,
	Donald Yandt <donald.yandt@gmail.com>
Subject: [PATCH resend] tools/perf/util/machine: Return NULL instead of null-terminating
Date: Tue, 28 May 2019 09:41:28 -0400	[thread overview]
Message-ID: <20190528134128.30841-1-donald.yandt@gmail.com> (raw)

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


             reply	other threads:[~2019-05-28 13:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 13:41 Donald Yandt [this message]
2019-05-30  8:14 ` [tip:perf/core] perf machine: Return NULL instead of null-terminating /proc/version array tip-bot for Donald Yandt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190528134128.30841-1-donald.yandt@gmail.com \
    --to=donald.yandt@gmail.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yanmin_zhang@linux.intel.com \
    --subject='Re: [PATCH resend] tools/perf/util/machine: Return NULL instead of null-terminating' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).