Skip to content

Commit

Permalink
trace: fix coverity warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh committed Dec 7, 2023
1 parent cbcabbc commit 452d062
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -196,6 +193,10 @@ int re_trace_init(const char *json_file)
}

return err;
#else
(void)json_file;
return 0;
#endif
}


Expand All @@ -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);
Expand All @@ -230,6 +228,9 @@ int re_trace_close(void)
trace.f = NULL;

return 0;
#else
return 0;
#endif
}


Expand All @@ -240,17 +241,14 @@ 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;
char json_arg[256] = {0};
char name[128] = {0};
char id_str[128] = {0};

#ifndef RE_TRACE_ENABLED
return 0;
#endif

if (!re_atomic_rlx(&trace.init))
return 0;

Expand Down Expand Up @@ -311,19 +309,19 @@ int re_trace_flush(void)

(void)fflush(trace.f);
return 0;
#else
return 0;
#endif
}


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;

Expand Down Expand Up @@ -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
}

0 comments on commit 452d062

Please sign in to comment.