coverage: attempt to use annotations to ignore defensive coding lines

pull/778/head
Brad House 9 months ago
parent 01d9c4c9c9
commit 9cfc468bec
  1. 16
      src/lib/ares__htable.c

@ -141,14 +141,14 @@ const void **ares__htable_all_buckets(const ares__htable_t *htable, size_t *num)
size_t cnt = 0;
size_t i;
if (htable == NULL || num == NULL) {
if (htable == NULL || num == NULL) { /* LCOV_EXCL_BR_LINE */
return NULL;
}
*num = 0;
out = ares_malloc_zero(sizeof(*out) * htable->num_keys);
if (out == NULL) {
if (out == NULL) { /* LCOV_EXCL_BR_LINE */
return NULL;
}
@ -196,7 +196,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
ares_bool_t rv = ARES_FALSE;
/* Not a failure, just won't expand */
if (old_size == ARES__HTABLE_MAX_BUCKETS) {
if (old_size == ARES__HTABLE_MAX_BUCKETS) { /* LCOV_EXCL_BR_LINE */
return ARES_TRUE;
}
@ -206,7 +206,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
* new hash array. Otherwise if there's a memory allocation failure in the
* middle, we wouldn't be able to recover. */
buckets = ares_malloc_zero(sizeof(*buckets) * htable->size);
if (buckets == NULL) {
if (buckets == NULL) { /* LCOV_EXCL_BR_LINE */
goto done;
}
@ -216,7 +216,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
if (prealloc_llist_len) {
prealloc_llist =
ares_malloc_zero(sizeof(*prealloc_llist) * prealloc_llist_len);
if (prealloc_llist == NULL) {
if (prealloc_llist == NULL) { /* LCOV_EXCL_BR_LINE */
goto done;
}
}
@ -269,7 +269,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
/* Grab one off our preallocated list */
if (buckets[idx] == NULL) {
/* Silence static analysis, this isn't possible but it doesn't know */
if (prealloc_llist == NULL || prealloc_llist_len == 0) {
if (prealloc_llist == NULL || prealloc_llist_len == 0) { /* LCOV_EXCL_BR_LINE */
goto done;
}
buckets[idx] = prealloc_llist[prealloc_llist_len - 1];
@ -303,7 +303,7 @@ done:
ARES_FALSE);
/* On failure, we need to restore the htable size */
if (rv != ARES_TRUE) {
if (rv != ARES_TRUE) { /* LCOV_EXCL_BR_LINE */
htable->size = old_size;
}
@ -335,7 +335,7 @@ ares_bool_t ares__htable_insert(ares__htable_t *htable, void *bucket)
* increased beyond our threshold */
if (htable->num_keys + 1 >
(htable->size * ARES__HTABLE_EXPAND_PERCENT) / 100) {
if (!ares__htable_expand(htable)) {
if (!ares__htable_expand(htable)) { /* LCOV_EXCL_BR_LINE */
return ARES_FALSE;
}
/* If we expanded, need to calculate a new index */

Loading…
Cancel
Save