From 59d8a0bb0fb8d58633d66361735aad664a61e707 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Thu, 28 Sep 2023 18:52:42 +0100 Subject: [PATCH] ctr_span: make NULL checks explicit Signed-off-by: David Korczynski --- src/ctr_decode_msgpack.c | 2 +- src/ctr_span.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ctr_decode_msgpack.c b/src/ctr_decode_msgpack.c index 83f9a19..0711aaf 100644 --- a/src/ctr_decode_msgpack.c +++ b/src/ctr_decode_msgpack.c @@ -124,7 +124,7 @@ static int unpack_instrumentation_scope_attributes(mpack_reader_t *reader, size_ return CTR_DECODE_MSGPACK_VARIANT_DECODE_ERROR; } - if (context->scope_span->instrumentation_scope->attr) { + if (context->scope_span->instrumentation_scope->attr != NULL) { ctr_attributes_destroy(context->scope_span->instrumentation_scope->attr); context->scope_span->instrumentation_scope->attr = NULL; } diff --git a/src/ctr_span.c b/src/ctr_span.c index ca283f1..3802857 100644 --- a/src/ctr_span.c +++ b/src/ctr_span.c @@ -116,7 +116,7 @@ int ctr_span_set_span_id(struct ctrace_span *span, void *buf, size_t len) if (!buf || len <= 0) { return -1; } - if (span->span_id) { + if (span->span_id != NULL) { ctr_id_destroy(span->span_id); } span->span_id = ctr_id_create(buf, len); @@ -296,27 +296,27 @@ void ctr_span_destroy(struct ctrace_span *span) struct ctrace_span_status *status; struct ctrace_link *link; - if (span->name) { + if (span->name != NULL) { cfl_sds_destroy(span->name); } - if (span->trace_id) { + if (span->trace_id != NULL) { ctr_id_destroy(span->trace_id); } - if (span->span_id) { + if (span->span_id != NULL) { ctr_id_destroy(span->span_id); } - if (span->parent_span_id) { + if (span->parent_span_id != NULL) { ctr_id_destroy(span->parent_span_id); } /* attributes */ - if (span->attr) { + if (span->attr != NULL) { ctr_attributes_destroy(span->attr); } - if (span->trace_state) { + if (span->trace_state != NULL) { cfl_sds_destroy(span->trace_state); } @@ -334,7 +334,7 @@ void ctr_span_destroy(struct ctrace_span *span) /* status */ status = &span->status; - if (status->message) { + if (status->message != NULL) { cfl_sds_destroy(status->message); }