Skip to content

Commit

Permalink
ctr_span: make NULL checks explicit
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski committed Sep 28, 2023
1 parent cd3eab8 commit 59d8a0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ctr_decode_msgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions src/ctr_span.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 59d8a0b

Please sign in to comment.