}
#endif
- if (!fr_cond_assert(IS_NODE(trie))) return NULL;
+ fr_cond_assert(IS_NODE(trie));
(void) talloc_steal(ctx, trie);
return trie;
}
}
#endif
- if (!fr_cond_assert(IS_NODE(trie))) return NULL;
+ fr_cond_assert(IS_NODE(trie));
return talloc_parent(trie);
}
#endif
(void) talloc_get_type_abort_const(node, fr_trie_node_t);
- if (!fr_cond_assert(node->size > 0)) return;
- if (!fr_cond_assert(node->size <= 8)) return;
- if (!fr_cond_assert(node->used >= 0)) return;
- if (!fr_cond_assert(node->used <= (1 << node->size))) return;
+ fr_cond_assert(node->size > 0);
+ fr_cond_assert(node->size <= 8);
+ fr_cond_assert(node->used >= 0);
+ fr_cond_assert(node->used <= (1 << node->size));
used = 0;
for (i = 0; i < (1 << node->size); i++) {
used++;
}
- if (!fr_cond_assert(used == node->used)) return;
+ fr_cond_assert(used == node->used);
}
#ifdef WITH_PATH_COMPRESSION
{
(void) talloc_get_type_abort_const(path, fr_trie_path_t);
- if (!fr_cond_assert(path->start_bit >= 0)) return;
- if (!fr_cond_assert(path->start_bit < 8)) return;
- if (!fr_cond_assert(path->length > 0)) return;
- if (!fr_cond_assert(path->length < (1 << 20))) return;
- if (!fr_cond_assert(path->end_bit > 0)) return;
- if (!fr_cond_assert(path->length < (1 << 20))) return;
- if (!fr_cond_assert((path->start_bit + path->length) == path->end_bit)) return;
+ fr_cond_assert(path->start_bit >= 0);
+ fr_cond_assert(path->start_bit < 8);
+ fr_cond_assert(path->length > 0);
+ fr_cond_assert(path->length < (1 << 20));
+ fr_cond_assert(path->end_bit > 0);
+ fr_cond_assert(path->length < (1 << 20));
+ fr_cond_assert((path->start_bit + path->length) == path->end_bit);
- if (!fr_cond_assert(path->key != NULL)) return;
- if (!fr_cond_assert(talloc_parent(path->key) == path)) return;
+ fr_cond_assert(path->key != NULL);
+ fr_cond_assert(talloc_parent(path->key) == path);
if ((path->start_bit == 0) && (path->length >= 8)) {
- if (!fr_cond_assert(path->key[0] > ' ')) return;
- if (!fr_cond_assert(path->key[0] < 0x7f)) return;
+ fr_cond_assert(path->key[0] > ' ');
+ fr_cond_assert(path->key[0] < 0x7f);
}
/*
int i;
for (i = 1; i < BYTEOF(path->end_bit); i++) {
- if (!fr_cond_assert(path->key[i] > ' ')) return;
- if (!fr_cond_assert(path->key[i] < 0x7f)) return;
+ fr_cond_assert(path->key[i] > ' ');
+ fr_cond_assert(path->key[i] < 0x7f);
}
}
- if (!fr_cond_assert(trie_parent(path->trie) == path)) return;
+ fr_cond_assert(trie_parent(path->trie) == path);
}
#endif /* WITH_PATH_COMPRESSION */
fr_trie_path_verify(path);
- if (!fr_cond_assert(trie_parent(path->trie) == path)) return;
+ fr_cond_assert(trie_parent(path->trie) == path);
fr_trie_verify(path->trie);
return;
}
for (i = 0; i < (1 << node->size); i++) {
if (!node->trie[i]) continue;
- if (!fr_cond_assert(trie_parent(node->trie[i]) == node)) return;
+ fr_cond_assert(trie_parent(node->trie[i]) == node);
fr_trie_verify(node->trie[i]);
}
int start_byte, end_byte;
if (!keylen1 || !keylen2) return 0;
- if (!fr_cond_assert((start_bit & 0x07) == start_bit)) return 0;
+ fr_cond_assert((start_bit & 0x07) == start_bit);
end_bit = keylen1;
if (end_bit > keylen2) end_bit = keylen2;
}
s2 = start_bit;
- if (!fr_cond_assert(s2 <= e2)) return 0;
+ fr_cond_assert(s2 <= e2);
xor = key1[0] ^ key2[0];
* do a separate bit check for the last byte.
*/
end_byte = BYTEOF(end_bit);
- if (!fr_cond_assert(start_byte <= end_byte)) return 0;
+ fr_cond_assert(start_byte <= end_byte);
bytes = 0;
s2 = 0;
e2 = 8;
} else {
- if (!fr_cond_assert(end_bit > s2)) return 0;
+ fr_cond_assert(end_bit > s2);
e2 = end_bit - s2;
s2 = 0;
}
lcp += xor2lcp[xor];
done:
- if (!fr_cond_assert(lcp <= keylen1)) return 0;
- if (!fr_cond_assert(lcp <= keylen2)) return 0;
+ fr_cond_assert(lcp <= keylen1);
+ fr_cond_assert(lcp <= keylen2);
return lcp;
}
fr_trie_path_t *path;
uint8_t *p;
- if (!fr_cond_assert(end_bit < MAX_KEY_BITS)) return NULL;
- if (!fr_cond_assert(end_bit > 0)) return NULL;
- if (!fr_cond_assert(start_bit < end_bit)) return NULL;
- if (!fr_cond_assert(!IS_PATH(trie))) return NULL;
+ fr_cond_assert(end_bit < MAX_KEY_BITS);
+ fr_cond_assert(end_bit > 0);
+ fr_cond_assert(start_bit < end_bit);
+ fr_cond_assert(!IS_PATH(trie));
path = talloc_zero(ctx, fr_trie_path_t);
if (!path) return NULL;
path->start_bit = start_bit & 0x07;
path->length = end_bit - start_bit;
path->end_bit = path->start_bit + path->length;
- if (!fr_cond_assert(path->length > 0)) return NULL;
+ fr_cond_assert(path->length > 0);
path->number = ft->number++;
path->key = p = talloc_memdup(path, key + BYTEOF(start_bit), BYTES(path->end_bit));
return -1;
}
- if (!fr_cond_assert(trie == small)) return -1;
+ fr_cond_assert(trie == small);
fr_trie_node_verify(small);
if (fr_trie_merge(ft, ctx, &trie, small, node, depth) < 0) {
return -1;
}
- if (!fr_cond_assert(trie == small)) return -1;
+ fr_cond_assert(trie == small);
fr_trie_node_verify(small);
*node_p = small;
fr_trie_path_verify(path1);
fr_trie_path_verify(path2);
- if (!fr_cond_assert(path1->start_bit == path2->start_bit)) return NULL;
+ fr_cond_assert(path1->start_bit == path2->start_bit);
/*
* Figure out which is the shorter of the two paths.
*/
size = DEFAULT_SIZE;
if (size > td_short->length) size = td_short->length;
- if (!fr_cond_assert(size > 0)) return NULL;
- if (!fr_cond_assert(size <= 8)) return NULL;
+ fr_cond_assert(size > 0);
+ fr_cond_assert(size <= 8);
node = fr_trie_node_alloc(ft, ctx, size);
if (!node) {
fr_trie_path_verify(path1);
fr_trie_path_verify(path2);
- if (!fr_cond_assert(path2->length > 0)) return NULL;
- if (!fr_cond_assert(path1->start_bit == path2->start_bit)) return NULL;
+ fr_cond_assert(path2->length > 0);
+ fr_cond_assert(path1->start_bit == path2->start_bit);
/*
* path1 is from the existing trie. path2 is the path we're trying to insert.
*/
- if (!fr_cond_assert(IS_USER(path2->trie))) return NULL;
+ fr_cond_assert(IS_USER(path2->trie));
(void) talloc_get_type_abort(path1, fr_trie_path_t);
}
if (!suffix1) {
- if (!fr_cond_assert(!IS_PATH(path1->trie))) return NULL;
+ fr_cond_assert(!IS_PATH(path1->trie));
if (fr_trie_merge(ft, prefix, &prefix->trie, path1->trie, PUT_PATH(suffix2), depth + prefix->length) < 0) {
talloc_free(prefix);
{
uint8_t *p, *q;
- if (!fr_cond_assert(((start_bit1 + keylen1) & 0x07) == start_bit2)) return -1;
+ fr_cond_assert(((start_bit1 + keylen1) & 0x07) == start_bit2);
p = talloc_array(path, uint8_t, BYTES(start_bit1 + keylen1 + keylen2));
if (!p) return -1;
return PUT_PATH(path);
}
- if (!fr_cond_assert(IS_PATH(trie))) return NULL;
+ fr_cond_assert(IS_PATH(trie));
path = GET_PATH(trie);
fr_trie_path_verify(path);
{
uint16_t chunk;
- if (!fr_cond_assert(num_bits > 0)) return 0;
- if (!fr_cond_assert(num_bits <= 8)) return 0;
- if (!fr_cond_assert(start_bit < end_bit)) return 0;
+ fr_cond_assert(num_bits > 0);
+ fr_cond_assert(num_bits <= 8);
+ fr_cond_assert(start_bit < end_bit);
/*
* Load the byte
for (i = 0; i < (1 << node1->size); i++) {
uint16_t j;
- if (!fr_cond_assert(bits < 8)) return -1;
+ fr_cond_assert(bits < 8);
for (j = 0; j < (1 << bits); j++) {
void *subtrie;
*/
subtrie = fr_trie_path_prefix_add(ft, node1, node2->trie[(i << bits) | j],
bits, j, depth);
- if (!fr_cond_assert(subtrie != NULL)) return -1;
+ fr_cond_assert(subtrie != NULL);
if (fr_trie_merge(ft, node1, &node1->trie[i],
node1->trie[i], subtrie, depth) < 0) {
*/
if (!node1->trie[i]) {
subnode = node1->trie[i] = fr_trie_node_alloc(ft, node1, bits);
- if (!fr_cond_assert(subnode != NULL)) return -1;
+ fr_cond_assert(subnode != NULL);
} else if (IS_NODE(node1->trie[i])) {
subnode = node1->trie[i];
- if (!fr_cond_assert(IS_NODE(subnode))) return -1;
+ fr_cond_assert(IS_NODE(subnode));
} else {
fr_trie_user_t *user;
- if (!fr_cond_assert(IS_USER(node1->trie[i]))) return -1;
+ fr_cond_assert(IS_USER(node1->trie[i]));
user = GET_USER(node1->trie[i]);
subtrie = user->trie;
if (!subtrie) {
subnode = user->trie = fr_trie_node_alloc(ft, user, bits);
- if (!fr_cond_assert(subnode != NULL)) return -1;
+ fr_cond_assert(subnode != NULL);
} else {
/*
* No path compression here.
*/
- if (!fr_cond_assert(IS_NODE(subtrie))) return -1;
+ fr_cond_assert(IS_NODE(subtrie));
subnode = subtrie;
- if (!fr_cond_assert(subnode->size == bits)) return -1;
+ fr_cond_assert(subnode->size == bits);
}
}
return 0;
}
- if (!fr_cond_assert(0 == 1)) return -1;
+ fr_cond_assert(0 == 1);
+
+ return -1;
}
path = GET_PATH(trie);
- if (!fr_cond_assert((start_bit & 0x07) == path->start_bit)) return -1;
+ fr_cond_assert((start_bit & 0x07) == path->start_bit);
/*
* See how long the common prefix is.
* path, and insert the key into it's child.
*/
if (lcp == path->length) {
- if (!fr_cond_assert(!IS_PATH(path->trie))) return -1;
+ fr_cond_assert(!IS_PATH(path->trie));
return fr_trie_key_insert(ft, path, &path->trie,
key, start_bit + lcp, end_bit, subtrie);
insert_node:
#endif
- if (!fr_cond_assert(IS_NODE(trie))) return -1;
+ fr_cond_assert(IS_NODE(trie));
node = trie;
fr_trie_node_verify(node);
node2 = fr_trie_node_alloc(ft, node, size);
if (!node2) {
+ fr_cond_assert(0 == 1);
MPRINT("FAILED %d\n", __LINE__);
-
- if (!fr_cond_assert(0 == 1)) return -1;
+ return -1;
}
chunk = get_chunk(key, size, start_bit, end_bit);
}
chunk = get_chunk(key, node->size, start_bit, end_bit);
- if (!fr_cond_assert(chunk < (1 << node->size))) return -1;
+ fr_cond_assert(chunk < (1 << node->size));
incr = (node->trie[chunk] == NULL);
rcode = fr_trie_key_insert(ft, node, &node->trie[chunk], key, next, end_bit, subtrie);
if (rcode < 0) return rcode;
- if (!fr_cond_assert(node->trie[chunk] != NULL)) return -1;
+ fr_cond_assert(node->trie[chunk] != NULL);
node->used += incr;
return 0;
}
}
- if (!fr_cond_assert(i < (1 << node->size))) return NULL;
+ fr_cond_assert(i < (1 << node->size));
/*
* Convert the node to a PATH.
* Nothing more to do, retun.
*/
if (!trie) {
- if (!fr_cond_assert(depth == 0)) return 0;
+ fr_cond_assert(depth == 0);
+ return 0;
}
/*
fr_trie_path_verify(path);
if (path->start_bit == 0) {
- if (!fr_cond_assert((depth & 0x07) == 0)) return -1;
+ fr_cond_assert((depth & 0x07) == 0);
memcpy(out, path->key, BYTES(path->length));
} else {
#ifdef WITH_TRIE_VERIFY
fr_trie_verify(ft->trie);
#else
- rad_assert(ft != NULL);
+ fr_cond_assert(ft != NULL);
#endif
return 0;
}