Skip to content

Commit

Permalink
Fixes for some build and static analyzer issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Potman <[email protected]>
  • Loading branch information
dpotman committed Sep 6, 2023
1 parent dfbb22e commit 3f7bcfc
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/core/ddsc/include/dds/ddsc/dds_psmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ DDS_EXPORT dds_return_t dds_psmx_cleanup_generic (struct dds_psmx *psmx);
* @param[in] topic_name the topic name
* @return a DDS return code
*/
DDS_EXPORT dds_return_t dds_psmx_topic_init_generic (struct dds_psmx_topic *topic, const struct dds_psmx *psmx, const char *topic_name);
DDS_EXPORT dds_return_t dds_psmx_topic_init_generic (struct dds_psmx_topic *psmx_topic, const struct dds_psmx *psmx, const char *topic_name);

/**
* @brief cleanup function for a topic
Expand Down
2 changes: 1 addition & 1 deletion src/core/ddsc/src/dds__loaned_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct dds_loan_pool dds_loan_pool_t;
* @param[in] initial_cap Initial capacity
* @return a DDS return code
*/
dds_return_t dds_loan_pool_create (dds_loan_pool_t **pool, uint32_t initial_cap)
dds_return_t dds_loan_pool_create (dds_loan_pool_t **ppool, uint32_t initial_cap)
ddsrt_nonnull_all;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/ddsc/src/dds__psmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dds_return_t dds_endpoint_add_psmx_endpoint (struct dds_endpoint *ep, const dds_
void dds_endpoint_remove_psmx_endpoints (struct dds_endpoint *ep);

struct ddsi_psmx_locators_set *dds_get_psmx_locators_set (const dds_qos_t *qos, const struct dds_psmx_set *psmx_instances);
void dds_psmx_locators_set_free (struct ddsi_psmx_locators_set *psmx_locators);
void dds_psmx_locators_set_free (struct ddsi_psmx_locators_set *psmx_locators_set);

/**
* @brief Request a loan
Expand Down
2 changes: 1 addition & 1 deletion src/core/ddsc/src/dds__qos.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern "C" {
dds_return_t dds_ensure_valid_data_representation (dds_qos_t *qos, uint32_t allowed_data_representations, bool topicqos);

/** @component qos_obj */
dds_return_t dds_ensure_valid_psmx_instances (dds_qos_t *qos, dds_psmx_endpoint_type_t forwhat, ddsi_data_type_properties_t data_type_props, const struct dds_psmx_set *psmx_set);
dds_return_t dds_ensure_valid_psmx_instances (dds_qos_t *qos, dds_psmx_endpoint_type_t forwhat, ddsi_data_type_properties_t data_type_props, const struct dds_psmx_set *psmx_instances);

/** @component qos_obj */
bool dds_qos_has_psmx_instances (const dds_qos_t *qos, const char *psmx_instance_name);
Expand Down
5 changes: 3 additions & 2 deletions src/core/ddsc/src/dds__writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ void dds_writer_status_cb (void *entity, const struct ddsi_status_cb_data * data
void dds_writer_invoke_cbs_for_pending_events(struct dds_entity *e, uint32_t status);

/** @component writer */
dds_return_t dds_return_writer_loan(dds_writer *writer, void **buf, int32_t bufsz) ddsrt_nonnull_all;
dds_return_t dds_return_writer_loan (dds_writer *wr, void **samples_ptr, int32_t n_samples) ddsrt_nonnull_all;

/** @component writer */
dds_return_t dds__ddsi_writer_wait_for_acks (struct dds_writer *wr, ddsi_guid_t *rdguid, dds_time_t abstimeout);

dds_return_t dds_request_writer_loan(dds_writer *wr, void **samples)
/** @component writer */
dds_return_t dds_request_writer_loan (dds_writer *wr, void **sample)
ddsrt_nonnull_all;

#if defined (__cplusplus)
Expand Down
4 changes: 2 additions & 2 deletions src/core/ddsc/src/dds_heap_loan.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void heap_loan_free (dds_loaned_sample_t *loaned_sample)
ddsrt_free (hl);
}

void dds_heap_loan_reset (dds_loaned_sample_t *loaned_sample)
void dds_heap_loan_reset (struct dds_loaned_sample *loaned_sample)
{
dds_heap_loan_t *hl = (dds_heap_loan_t *) loaned_sample;
memset (hl->c.metadata, 0, sizeof (*(hl->c.metadata)));
Expand All @@ -45,7 +45,7 @@ const dds_loaned_sample_ops_t dds_loan_heap_ops = {
.free = heap_loan_free
};

dds_return_t dds_heap_loan (const struct ddsi_sertype *type, dds_loaned_sample_state_t sample_state, dds_loaned_sample_t **loaned_sample)
dds_return_t dds_heap_loan (const struct ddsi_sertype *type, dds_loaned_sample_state_t sample_state, struct dds_loaned_sample **loaned_sample)
{
assert (sample_state == DDS_LOANED_SAMPLE_STATE_RAW_KEY || sample_state == DDS_LOANED_SAMPLE_STATE_RAW_DATA);

Expand Down
16 changes: 8 additions & 8 deletions src/core/ddsc/src/dds_psmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
static struct dds_psmx_endpoint * psmx_create_endpoint (struct dds_psmx_topic *psmx_topic, const struct dds_qos *qos, dds_psmx_endpoint_type_t endpoint_type);
static dds_return_t psmx_delete_endpoint (struct dds_psmx_endpoint *psmx_endpoint);

dds_return_t dds_add_psmx_topic_to_list (struct dds_psmx_topic *topic, struct dds_psmx_topic_list_elem **list)
dds_return_t dds_add_psmx_topic_to_list (struct dds_psmx_topic *psmx_topic, struct dds_psmx_topic_list_elem **list)
{
if (!topic)
if (!psmx_topic)
return DDS_RETCODE_BAD_PARAMETER;

struct dds_psmx_topic_list_elem *ptr = dds_alloc (sizeof (struct dds_psmx_topic_list_elem));
if (!ptr)
return DDS_RETCODE_OUT_OF_RESOURCES;

ptr->topic = topic;
ptr->topic = psmx_topic;
ptr->next = NULL;

if (!*list)
Expand All @@ -54,15 +54,15 @@ dds_return_t dds_add_psmx_topic_to_list (struct dds_psmx_topic *topic, struct dd
return DDS_RETCODE_OK;
}

dds_return_t dds_remove_psmx_topic_from_list (struct dds_psmx_topic *topic, struct dds_psmx_topic_list_elem **list)
dds_return_t dds_remove_psmx_topic_from_list (struct dds_psmx_topic *psmx_topic, struct dds_psmx_topic_list_elem **list)
{
if (!topic || !list || !*list)
if (!psmx_topic || !list || !*list)
return DDS_RETCODE_BAD_PARAMETER;

dds_return_t ret = DDS_RETCODE_OK;
struct dds_psmx_topic_list_elem *list_entry = *list;

while (list_entry && list_entry->topic != topic)
while (list_entry && list_entry->topic != psmx_topic)
list_entry = list_entry->next;

if (list_entry != NULL && (ret = list_entry->topic->psmx_instance->ops.delete_topic (list_entry->topic)) == DDS_RETCODE_OK)
Expand Down Expand Up @@ -257,7 +257,7 @@ static int compare_psmx_prio (const void *va, const void *vb)
return (psmx1->priority == psmx2->priority) ? 0 : ((psmx1->priority < psmx2->priority) ? 1 : -1);
}

dds_return_t dds_pubsub_message_exchange_init (const struct ddsi_domaingv *gv, dds_domain *domain)
dds_return_t dds_pubsub_message_exchange_init (const struct ddsi_domaingv *gv, struct dds_domain *domain)
{
dds_return_t ret = DDS_RETCODE_OK;
if (gv->config.psmx_instances != NULL)
Expand All @@ -283,7 +283,7 @@ dds_return_t dds_pubsub_message_exchange_init (const struct ddsi_domaingv *gv, d
return ret;
}

dds_return_t dds_pubsub_message_exchange_fini (dds_domain *domain)
dds_return_t dds_pubsub_message_exchange_fini (struct dds_domain *domain)
{
dds_return_t ret = DDS_RETCODE_OK;
for (uint32_t i = 0; ret == DDS_RETCODE_OK && i < domain->psmx_instances.length; i++)
Expand Down
18 changes: 11 additions & 7 deletions src/core/ddsc/src/dds_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,20 @@ dds_return_t dds_request_writer_loan (dds_writer *wr, void **sample)

dds_loaned_sample_t *loan;
if (wr->m_endpoint.psmx_endpoints.length > 0 && wr->m_topic->m_stype->fixed_size)
loan = dds_psmx_endpoint_request_loan (wr->m_endpoint.psmx_endpoints.endpoints[0], wr->m_topic->m_stype->zerocopy_size);
{
if ((loan = dds_psmx_endpoint_request_loan (wr->m_endpoint.psmx_endpoints.endpoints[0], wr->m_topic->m_stype->zerocopy_size)) == NULL)
ret = DDS_RETCODE_ERROR;
}
else if ((ret = dds_heap_loan (wr->m_topic->m_stype, DDS_LOANED_SAMPLE_STATE_RAW_DATA, &loan)) != DDS_RETCODE_OK)
loan = NULL;

if (loan == NULL)
ret = DDS_RETCODE_ERROR;
else if ((ret = dds_loan_pool_add_loan (wr->m_loans, loan)) != DDS_RETCODE_OK)
dds_loaned_sample_unref (loan);
else
*sample = loan->sample_ptr;
if (loan != NULL)
{
if ((ret = dds_loan_pool_add_loan (wr->m_loans, loan)) != DDS_RETCODE_OK)
dds_loaned_sample_unref (loan);
else
*sample = loan->sample_ptr;
}
ddsrt_mutex_unlock (&wr->m_entity.m_mutex);
return ret;
}
Expand Down
12 changes: 6 additions & 6 deletions src/core/ddsi/tests/wraddrset.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ static void ddsi_wraddrset_some_cases (int casenumber, int cost, bool wr_psmx, c
}
const ddsi_plist_t plist_pp[4] = { PLIST_PP(0), PLIST_PP(1), PLIST_PP(2), PLIST_PP(3) };
ddsi_guid_t wrppguid, rdppguid[4][3];

setup_and_start ();
ddsi_thread_state_awake (ddsi_lookup_thread_state(), &gv);
ddsi_new_participant (&wrppguid, &gv, RTPS_PF_PRIVILEGED_PP | RTPS_PF_IS_DDSI2_PP, &plist_pp[0]);

const struct ddsi_sertype st = {
.ops = &(struct ddsi_sertype_ops){ .free = sertype_free },
.serdata_ops = &(struct ddsi_serdata_ops){ },
.serdata_ops = &(struct ddsi_serdata_ops){ NULL },
.serdata_basehash = 0,
.typekind_no_key = 1,
.request_keyhash = 0,
Expand All @@ -161,7 +161,7 @@ static void ddsi_wraddrset_some_cases (int casenumber, int cost, bool wr_psmx, c
.zerocopy_size = 8,
.data_type_props = DDS_DATA_TYPE_IS_FIXED_SIZE
};

struct ddsi_participant *pp = ddsi_entidx_lookup_participant_guid (gv.entity_index, &wrppguid);
struct ddsi_writer *wr;
ddsi_guid_t wrguid;
Expand All @@ -176,7 +176,7 @@ static void ddsi_wraddrset_some_cases (int casenumber, int cost, bool wr_psmx, c
};
ddsi_new_writer (&wr, &wrguid, NULL, pp, "Q", &st, &ddsi_default_qos_writer, &whc, NULL, NULL, wr_psmx ? &psmx_locs : NULL);
assert (ddsi_entidx_lookup_writer_guid (gv.entity_index, &wrguid));

struct ddsi_tran_conn fake_conn = {
.m_factory = ddsi_factory_find_supported_kind (&gv, DDSI_LOCATOR_KIND_PSMX),
.m_interf = &(struct ddsi_network_interface){
Expand Down Expand Up @@ -224,7 +224,7 @@ static void ddsi_wraddrset_some_cases (int casenumber, int cost, bool wr_psmx, c
ddsi_unref_addrset (rd_as);
}
}

if (casenumber == 0)
DDS_CLOG (DDS_LC_CONTENT, &gv.logconfig, " #rd/host cost: addresses\n");
DDS_CLOG (DDS_LC_CONTENT, &gv.logconfig, "%2d ", casenumber+1);
Expand Down

0 comments on commit 3f7bcfc

Please sign in to comment.