summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorTomas Krizek <tomas.krizek@nic.cz>2021-05-25 14:17:23 +0200
committerTomas Krizek <tomas.krizek@nic.cz>2021-05-25 14:40:30 +0200
commit2bc7b1e51318dc882c1f84073e9880cb77570bf7 (patch)
treece932523c65e0997d5291e90083b976d80f59896 /utils
parentlib/dnssec/ta.c: replace asserts (diff)
downloadknot-resolver-2bc7b1e51318dc882c1f84073e9880cb77570bf7.tar.xz
knot-resolver-2bc7b1e51318dc882c1f84073e9880cb77570bf7.zip
treewide: rename assumptions to kr_assert() / kr_fails_assert()
To (hopefully) improve readability, rename the typical macro usage of: if (!kr_assume(x)) y; // to if (kr_fails_assert(x)) y; As a convenience, replace the assert without a return value to a more simple version: (void)!kr_assume(x); // becomes kr_assert(x);
Diffstat (limited to 'utils')
-rw-r--r--utils/cache_gc/db.c6
-rw-r--r--utils/cache_gc/kr_cache_gc.c4
-rw-r--r--utils/cache_gc/main.c4
3 files changed, 7 insertions, 7 deletions
diff --git a/utils/cache_gc/db.c b/utils/cache_gc/db.c
index d164ea7b..3b4a75be 100644
--- a/utils/cache_gc/db.c
+++ b/utils/cache_gc/db.c
@@ -76,7 +76,7 @@ int kr_gc_key_consistent(knot_db_val_t key)
} else {
/* find the first double zero in the key */
for (i = 2; kd[i - 1] || kd[i - 2]; ++i) {
- if (!kr_assume(i < key.len))
+ if (kr_fails_assert(i < key.len))
return kr_error(EINVAL);
}
}
@@ -85,7 +85,7 @@ int kr_gc_key_consistent(knot_db_val_t key)
case 'E':
(void)0; // C can't have a variable definition following a label
uint16_t type;
- if (!kr_assume(i + 1 + sizeof(type) <= key.len))
+ if (kr_fails_assert(i + 1 + sizeof(type) <= key.len))
return kr_error(EINVAL);
memcpy(&type, kd + i + 1, sizeof(type));
return type;
@@ -96,7 +96,7 @@ int kr_gc_key_consistent(knot_db_val_t key)
case 'S': // the rtt_state entries are considered inconsistent, at least for now
return -1;
default:
- (void)!kr_assume(!EINVAL);
+ kr_assert(!EINVAL);
return kr_error(EINVAL);
}
}
diff --git a/utils/cache_gc/kr_cache_gc.c b/utils/cache_gc/kr_cache_gc.c
index a35c393b..baf8644f 100644
--- a/utils/cache_gc/kr_cache_gc.c
+++ b/utils/cache_gc/kr_cache_gc.c
@@ -151,7 +151,7 @@ struct kr_cache_gc_state {
void kr_cache_gc_free_state(kr_cache_gc_state_t **state)
{
- if (!kr_assume(state))
+ if (kr_fails_assert(state))
return;
if (!*state) { // not open
return;
@@ -165,7 +165,7 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg, kr_cache_gc_state_t **state)
{
// The whole function works in four "big phases":
//// 1. find out whether we should even do analysis and deletion.
- if (!kr_assume(cfg && state))
+ if (kr_fails_assert(cfg && state))
return KNOT_EINVAL;
int ret;
// Ensure that we have open and "healthy" cache.
diff --git a/utils/cache_gc/main.c b/utils/cache_gc/main.c
index 5a0c4bd4..4656073a 100644
--- a/utils/cache_gc/main.c
+++ b/utils/cache_gc/main.c
@@ -26,7 +26,7 @@ static void got_killed(int signum)
case 3:
abort();
default:
- (void)!kr_assume(false);
+ kr_assert(false);
}
}
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
print_help();
return 1;
default:
- (void)!kr_assume(false);
+ kr_assert(false);
}
}