libtracecmd: Do not set errno to zero
PATCH 1/1 libtracecmd: Do not set errno to zero
From: "Steven Rostedt (Google)" <[email protected]>
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) <[email protected]>
--- lib/trace-cmd/trace-compress-zstd.c | 1 - lib/trace-cmd/trace-util.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-)
lib/trace-cmd/trace-compress-zstd.c +0 -1
@@ -46,7 +46,6 @@ static int zstd_decompress(void *ctx, const void *in, int in_bytes, void *out, ireturn -1 ; } - errno =0 ;return ret; }
lib/trace-cmd/trace-util.c +4 -4
@@ -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 */
Signature · 1 line
2.34.1