Skip to content

Commit

Permalink
Add Coverity annotations to mark issues false positives or intentional
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Potman <[email protected]>
  • Loading branch information
dpotman authored and eboasson committed Aug 23, 2022
1 parent 65e8d8f commit 1e1645c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/ddsc/tests/xtypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ CU_Test (ddsc_xtypes, invalid_top_level_local_hash, .init = xtypes_init, .fini =

for (uint32_t n = 0; n < 6; n++)
{
// coverity[store_writes_const_field]
memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc));
typeinfo_deser (&ti, &desc.type_information);
if (n % 2)
Expand Down Expand Up @@ -656,6 +657,7 @@ CU_Test (ddsc_xtypes, invalid_top_level_local_non_hash, .init = xtypes_init, .fi
char topic_name[100];

dds_topic_descriptor_t desc;
// coverity[store_writes_const_field]
memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc));

DDS_XTypes_TypeInformation *ti;
Expand Down Expand Up @@ -720,6 +722,7 @@ static void mod_arraybound (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair

static void modify_type_meta (dds_topic_descriptor_t *dst_desc, const dds_topic_descriptor_t *src_desc, typeobj_modify mod, bool update_typeinfo, uint32_t kind)
{
// coverity[store_writes_const_field]
memcpy (dst_desc, src_desc, sizeof (*dst_desc));

DDS_XTypes_TypeInformation *ti = NULL;
Expand Down Expand Up @@ -844,6 +847,7 @@ CU_Test (ddsc_xtypes, invalid_top_level_remote_hash, .init = xtypes_init, .fini
CU_ASSERT_FATAL (topic > 0);

// create type id with invalid top-level
// coverity[store_writes_const_field]
memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc));
typeinfo_deser (&ti, &desc.type_information);
ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id);
Expand Down
1 change: 1 addition & 0 deletions src/core/ddsi/src/ddsi_typebuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,7 @@ static dds_return_t get_topic_descriptor (dds_topic_descriptor_t *desc, struct t
ret = DDS_RETCODE_OUT_OF_RESOURCES;
goto err;
}
// coverity[store_writes_const_field]
memcpy (desc, &d, sizeof (*desc));
ret = DDS_RETCODE_OK;

Expand Down
6 changes: 5 additions & 1 deletion src/core/ddsi/tests/radmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void setup (void)
// internal processing has various asserts that it isn't an application thread
// doing the dirty work
thrst = lookup_thread_state ();
// coverity[missing_lock:FALSE]
assert (thrst->state == THREAD_STATE_LAZILY_CREATED);
thrst->state = THREAD_STATE_ALIVE;
ddsrt_atomic_stvoidp (&thrst->gv, &gv);
Expand All @@ -62,6 +63,7 @@ static void teardown (void)

// On shutdown, there is an expectation that the thread was discovered dynamically.
// We overrode it in the setup code, we undo it now.
// coverity[missing_lock:FALSE]
thrst->state = THREAD_STATE_LAZILY_CREATED;
thread_states_fini ();
ddsi_iid_fini ();
Expand Down Expand Up @@ -109,6 +111,8 @@ static void check_reorder (struct nn_reorder *reorder, uint64_t ndiscard, seqno_
static void insert_sample (struct nn_defrag *defrag, struct nn_reorder *reorder, struct nn_rmsg *rmsg, struct receiver_state *rst, seqno_t seq)
{
struct nn_rsample_info *si = nn_rmsg_alloc (rmsg, sizeof (*si));
CU_ASSERT_FATAL (si != NULL);
assert (si);
// only "seq" and "size" really matter
memset (si, 0, sizeof (*si));
si->rst = rst;
Expand All @@ -117,7 +121,7 @@ static void insert_sample (struct nn_defrag *defrag, struct nn_reorder *reorder,
struct nn_rdata *rdata = nn_rdata_new (rmsg, 0, si->size, 0, 0, 0);
struct nn_rsample *rsample = nn_defrag_rsample (defrag, rdata, si);
CU_ASSERT_FATAL (rsample != NULL);

struct nn_rsample_chain sc;
int refc_adjust = 0;
struct nn_rdata *fragchain = nn_rsample_fragchain (rsample);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ static bool read_submsg_header (tainted_input_buffer_t *input, uint8_t smid, Sub

// silly C can't deal with assignment to *submsg_view in any way because of endp
// memcpy to the rescue!
// coverity[store_writes_const_field]
memcpy (submsg_view, &(tainted_input_buffer_t){ .ptr = input->ptr, .endp = input->ptr + hdr->octetsToNextHeader }, sizeof (*submsg_view));
input->ptr += hdr->octetsToNextHeader;
return true;
Expand Down

0 comments on commit 1e1645c

Please sign in to comment.