* [PATCH] libtracecmd: Do not set errno to zero
@ 2022-03-07 2:36 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-03-07 2:36 UTC (permalink / raw)
To: Linux Trace Devel; +Cc: Sebastian Andrzej Siewior
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-07 2:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-07 2:36 [PATCH] libtracecmd: Do not set errno to zero Steven Rostedt
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).