Skip to content

Commit

Permalink
Remove unnecessary copying of pointer before return in cbor_load() (#223
Browse files Browse the repository at this point in the history
)

When building with TI ARM Clang compiler the initialization of
result_item generated a warning because of the goto statements earlier:

"error #548-D: transfer of control bypasses initialization of..."

This warning can be suppressed but since the copying of context.root is
unnecessary, we can simplify things and return the member right away.
  • Loading branch information
metmo committed Jun 17, 2022
1 parent 25d86a7 commit e87d571
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ cbor_item_t *cbor_load(cbor_data source, size_t source_size,
}
} while (stack.size > 0);

/* Move the result before free */
cbor_item_t *result_item = context.root;
return result_item;
return context.root;

error:
result->error.position = result->read;
Expand Down

0 comments on commit e87d571

Please sign in to comment.