trivial modifications to pacify gcc -O2 and clang --analyze

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-01-02 12:09:15 +01:00
parent b70e88c16f
commit ed06ab8f4b
19 changed files with 106 additions and 116 deletions

View file

@ -370,7 +370,8 @@ dds__builtin_write(
_In_ nn_wctime_t timestamp,
_In_ bool alive)
{
dds_entity_t topic;
/* initialize to avoid compiler warning ultimately caused by C's horrible type system */
dds_entity_t topic = 0;
switch (type)
{
case DSBT_PARTICIPANT:
@ -383,6 +384,7 @@ dds__builtin_write(
topic = DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION;
break;
}
assert(topic != 0);
(void)dds__builtin_write_int(topic, guid, timestamp.v, alive);
}

View file

@ -1120,6 +1120,16 @@ dds_triggered(
}
static bool in_observer_list_p (const struct dds_entity *observed, const dds_entity_t observer)
{
dds_entity_observer *cur;
for (cur = observed->m_observers; cur != NULL; cur = cur->m_next) {
if (cur->m_observer == observer) {
return true;
}
}
return false;
}
_Check_return_ dds__retcode_t
dds_entity_observer_register_nl(
@ -1127,30 +1137,19 @@ dds_entity_observer_register_nl(
_In_ dds_entity_t observer,
_In_ dds_entity_callback cb)
{
dds__retcode_t rc = DDS_RETCODE_OK;
dds__retcode_t rc;
dds_entity_observer *o = os_malloc(sizeof(dds_entity_observer));
assert(observed);
o->m_cb = cb;
o->m_observer = observer;
o->m_next = NULL;
os_mutexLock(&observed->m_observers_lock);
if (observed->m_observers == NULL) {
observed->m_observers = o;
if (in_observer_list_p (observed, observer)) {
rc = DDS_RETCODE_PRECONDITION_NOT_MET;
os_free (o);
} else {
dds_entity_observer *last;
dds_entity_observer *idx = observed->m_observers;
while ((idx != NULL) && (o != NULL)) {
if (idx->m_observer == observer) {
os_free(o);
o = NULL;
rc = DDS_RETCODE_PRECONDITION_NOT_MET;
}
last = idx;
idx = idx->m_next;
}
if (o != NULL) {
last->m_next = o;
}
rc = DDS_RETCODE_OK;
o->m_next = observed->m_observers;
observed->m_observers = o;
}
os_mutexUnlock(&observed->m_observers_lock);
return rc;

View file

@ -325,14 +325,12 @@ dds_reader_status_cb(
/* There's a deletion or closing going on. */
}
} else if (rc == DDS_RETCODE_NO_DATA) {
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status. */
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status, consider successful. */
dds_entity_status_set(entity, data->status);
/* Notify possible interested observers. */
dds_entity_status_signal(entity);
rc = DDS_RETCODE_OK;
} else if (rc == DDS_RETCODE_ALREADY_DELETED) {
/* An entity up the hierarchy is being deleted. */
rc = DDS_RETCODE_OK;
/* An entity up the hierarchy is being deleted, consider successful. */
} else {
/* Something went wrong up the hierarchy. */
}

View file

@ -367,6 +367,7 @@ static void remove_inst_from_nonempty_list (struct rhc *rhc, struct rhc_instance
#ifndef NDEBUG
{
const struct rhc_instance *x = rhc->nonempty_instances;
assert (x);
do { if (x == inst) break; x = x->next; } while (x != rhc->nonempty_instances);
assert (x == inst);
}
@ -2132,7 +2133,7 @@ void dds_rhc_add_readcondition (dds_readcond * cond)
DDS_TRACE("add_readcondition(%p, %x, %x, %x) => %p qminv %x ; rhc %u conds\n",
(void *) rhc, cond->m_sample_states, cond->m_view_states,
cond->m_instance_states, cond, cond->m_qminv, rhc->nconds);
cond->m_instance_states, (void *) cond, cond->m_qminv, rhc->nconds);
os_mutexUnlock (&rhc->conds_lock);
os_mutexUnlock (&rhc->lock);

View file

@ -130,14 +130,12 @@ dds_topic_status_cb(
dds_topic_unlock(topic);
}
} else if (rc == DDS_RETCODE_NO_DATA) {
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status. */
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status; consider it successful. */
dds_entity_status_set((dds_entity*)topic, DDS_INCONSISTENT_TOPIC_STATUS);
/* Notify possible interested observers. */
dds_entity_status_signal((dds_entity*)topic);
rc = DDS_RETCODE_OK;
} else if (rc == DDS_RETCODE_ALREADY_DELETED) {
/* An entity up the hierarchy is being deleted. */
rc = DDS_RETCODE_OK;
/* An entity up the hierarchy is being deleted; consider it successful. */
} else {
/* Something went wrong up the hierarchy. */
}
@ -318,7 +316,7 @@ static bool dupdef_qos_ok(const dds_qos_t *qos, const struct ddsi_sertopic *st)
static bool sertopic_equivalent (const struct ddsi_sertopic *a, const struct ddsi_sertopic *b)
{
printf ("sertopic_equivalent %p %p (%s %s; %u %u; %p %p; %p %p)\n", a, b, a->name_typename, b->name_typename, a->serdata_basehash, b->serdata_basehash, a->ops, b->ops, a->serdata_ops, b->serdata_ops);
printf ("sertopic_equivalent %p %p (%s %s; %u %u; %p %p; %p %p)\n", (void*)a, (void*)b, a->name_typename, b->name_typename, a->serdata_basehash, b->serdata_basehash, (void *)a->ops, (void *)b->ops, (void *)a->serdata_ops, (void *)b->serdata_ops);
if (strcmp (a->name_typename, b->name_typename) != 0)
return false;

View file

@ -170,14 +170,12 @@ dds_writer_status_cb(
/* There's a deletion or closing going on. */
}
} else if (rc == DDS_RETCODE_NO_DATA) {
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status. */
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status; consider it successful. */
dds_entity_status_set(entity, data->status);
/* Notify possible interested observers. */
dds_entity_status_signal(entity);
rc = DDS_RETCODE_OK;
} else if (rc == DDS_RETCODE_ALREADY_DELETED) {
/* An entity up the hierarchy is being deleted. */
rc = DDS_RETCODE_OK;
/* An entity up the hierarchy is being deleted; consider it successful. */
} else {
/* Something went wrong up the hierarchy. */
}
@ -395,12 +393,6 @@ static struct whc *make_whc(const dds_qos_t *qos)
} else {
tldepth = 0;
}
if (hdepth == 0 && tldepth == 0)
{
/* no index at all - so no need to bother with startup mode */
startup_mode = 0;
}
return whc_new (handle_as_transient_local, hdepth, tldepth);
}