linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH] libtracecmd: Do not set errno to zero
Date: Sun, 6 Mar 2022 21:36:26 -0500	[thread overview]
Message-ID: <20220306213626.39b45180@rorschach.local.home> (raw)

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Libraries may set errno when an error happens, but it is in bad form to
clear errno on success.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-compress-zstd.c | 1 -
 lib/trace-cmd/trace-util.c          | 8 ++++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/trace-cmd/trace-compress-zstd.c b/lib/trace-cmd/trace-compress-zstd.c
index 3e42fc794502..10ae7a4c03c0 100644
--- a/lib/trace-cmd/trace-compress-zstd.c
+++ b/lib/trace-cmd/trace-compress-zstd.c
@@ -46,7 +46,6 @@ static int zstd_decompress(void *ctx, const void *in, int in_bytes, void *out, i
 		return -1;
 	}
 
-	errno = 0;
 	return ret;
 }
 
diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c
index 91e8a30fb90b..b5a0a1a601d4 100644
--- a/lib/trace-cmd/trace-util.c
+++ b/lib/trace-cmd/trace-util.c
@@ -131,6 +131,7 @@ void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent,
 			 char *file, unsigned int size __maybe_unused)
 {
 	unsigned long long addr;
+	int sav_errno;
 	char *func;
 	char *line;
 	char *next = NULL;
@@ -144,13 +145,13 @@ void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent,
 		int n;
 
 		mod = NULL;
+		sav_errno = errno;
 		errno = 0;
 		n = sscanf(line, "%16llx %c %n%*s%n%*1[\t][%n%*s%n",
 			   &addr, &ch, &func_start, &func_end, &mod_start, &mod_end);
-		if (errno) {
-			perror("sscanf");
+		if (errno)
 			return;
-		}
+		errno = sav_errno;
 
 		if (n != 2 || !func_end)
 			return;
@@ -521,7 +522,6 @@ int tracecmd_stack_tracer_status(int *status)
 
 	buf[n] = 0;
 
-	errno = 0;
 	num = strtol(buf, NULL, 10);
 
 	/* Check for various possible errors */
-- 
2.34.1


                 reply	other threads:[~2022-03-07  2:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220306213626.39b45180@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-trace-devel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).