From 452d0622ea13b513873174c4b6083f747374a437 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 7 Dec 2023 19:48:22 +0100 Subject: [PATCH 1/2] trace: fix coverity warnings --- src/trace/trace.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/trace/trace.c b/src/trace/trace.c index 980d41860..b95a53d06 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -144,12 +144,9 @@ static void flush_tmr(void *arg) */ int re_trace_init(const char *json_file) { +#ifdef RE_TRACE_ENABLED int err = 0; -#ifndef RE_TRACE_ENABLED - return 0; -#endif - if (!json_file) return EINVAL; @@ -196,6 +193,10 @@ int re_trace_init(const char *json_file) } return err; +#else + (void)json_file; + return 0; +#endif } @@ -206,12 +207,9 @@ int re_trace_init(const char *json_file) */ int re_trace_close(void) { +#ifdef RE_TRACE_ENABLED int err = 0; -#ifndef RE_TRACE_ENABLED - return 0; -#endif - tmr_cancel(&trace.flush_tmr); re_trace_flush(); re_atomic_rlx_set(&trace.init, false); @@ -230,6 +228,9 @@ int re_trace_close(void) trace.f = NULL; return 0; +#else + return 0; +#endif } @@ -240,6 +241,7 @@ int re_trace_close(void) */ int re_trace_flush(void) { +#ifdef RE_TRACE_ENABLED int i, flush_count; struct trace_event *event_tmp; struct trace_event *e; @@ -247,10 +249,6 @@ int re_trace_flush(void) char name[128] = {0}; char id_str[128] = {0}; -#ifndef RE_TRACE_ENABLED - return 0; -#endif - if (!re_atomic_rlx(&trace.init)) return 0; @@ -311,6 +309,9 @@ int re_trace_flush(void) (void)fflush(trace.f); return 0; +#else + return 0; +#endif } @@ -318,12 +319,9 @@ void re_trace_event(const char *cat, const char *name, char ph, struct pl *id, re_trace_arg_type arg_type, const char *arg_name, void *arg_value) { +#ifdef RE_TRACE_ENABLED struct trace_event *e; -#ifndef RE_TRACE_ENABLED - return; -#endif - if (!re_atomic_rlx(&trace.init)) return; @@ -361,4 +359,13 @@ void re_trace_event(const char *cat, const char *name, char ph, struct pl *id, (const char *)arg_value); break; } +#else + (void)cat; + (void)name; + (void)ph; + (void)id; + (void)arg_type; + (void)arg_name; + (void)arg_value; +#endif } From 0bb3ff4bc0708edd2f4d600ff6a2e23b778c39e8 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 7 Dec 2023 19:53:48 +0100 Subject: [PATCH 2/2] trace: add RE_TRACE_ENABLED --- src/trace/trace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/trace/trace.c b/src/trace/trace.c index b95a53d06..832d0f977 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -46,6 +46,8 @@ #endif +#ifdef RE_TRACE_ENABLED + struct trace_event { const char *name; const char *cat; @@ -133,6 +135,7 @@ static void flush_tmr(void *arg) tmr_start(&trace.flush_tmr, TRACE_FLUSH_TMR, flush_tmr, NULL); } +#endif /**