[PATCH] libtracecmd: Do not set errno to zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux