Remove pointless nullity check on array address

assoc->self_client_id is always true, therefore we can remove it from that if" -m "The if thus asserts !assoc->self_hash, so we can elide the immediately following if (!assoc->self_hash)
This commit is contained in:
tux3 2015-05-19 19:53:55 +02:00
parent 8760aba257
commit 19bd38999b
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -510,20 +510,18 @@ static uint8_t candidates_create_new(const Assoc *assoc, hash_t hash, const uint
static void client_id_self_update(Assoc *assoc) static void client_id_self_update(Assoc *assoc)
{ {
if (assoc->self_hash || !assoc->self_client_id) if (assoc->self_hash)
return; return;
if (!assoc->self_hash) { size_t i, sum = 0;
size_t i, sum = 0;
for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++)
sum |= assoc->self_client_id[i]; sum |= assoc->self_client_id[i];
if (!sum) if (!sum)
return; return;
assoc->self_hash = id_hash(assoc, assoc->self_client_id); assoc->self_hash = id_hash(assoc, assoc->self_client_id);
}
LOGGER_DEBUG("id is now set, purging cache of self-references"); LOGGER_DEBUG("id is now set, purging cache of self-references");
@ -532,7 +530,7 @@ static void client_id_self_update(Assoc *assoc)
*/ */
bucket_t b_id = candidates_id_bucket(assoc, assoc->self_client_id); bucket_t b_id = candidates_id_bucket(assoc, assoc->self_client_id);
candidates_bucket *cnd_bckt = &assoc->candidates[b_id]; candidates_bucket *cnd_bckt = &assoc->candidates[b_id];
size_t i, pos = assoc->self_hash % assoc->candidates_bucket_size; size_t pos = assoc->self_hash % assoc->candidates_bucket_size;
for (i = 0; i < HASH_COLLIDE_COUNT; pos = hash_collide(assoc, pos), i++) { for (i = 0; i < HASH_COLLIDE_COUNT; pos = hash_collide(assoc, pos), i++) {
Client_entry *entry = &cnd_bckt->list[pos]; Client_entry *entry = &cnd_bckt->list[pos];