Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace: fix coverity warnings #1024

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#endif


#ifdef RE_TRACE_ENABLED

struct trace_event {
const char *name;
const char *cat;
Expand Down Expand Up @@ -133,6 +135,7 @@ static void flush_tmr(void *arg)

tmr_start(&trace.flush_tmr, TRACE_FLUSH_TMR, flush_tmr, NULL);
}
#endif


/**
Expand All @@ -144,12 +147,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 +196,10 @@ int re_trace_init(const char *json_file)
}

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


Expand All @@ -206,12 +210,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 +231,9 @@ int re_trace_close(void)
trace.f = NULL;

return 0;
#else
return 0;
#endif
}


Expand All @@ -240,17 +244,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 +312,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 +362,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
}
Loading