Skip to content
Snippets Groups Projects
Verified Commit fb48ddb9 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček
Browse files

utils/kr_cache_gc: minor nitpicks

It should be no real change, just better readability, hopefully.
parent 828db96d
No related branches found
No related tags found
1 merge request!817cache garbage collector
......@@ -90,20 +90,20 @@ const uint16_t *kr_gc_key_consistent(knot_db_val_t key)
{
const static uint16_t NSEC1 = KNOT_RRTYPE_NSEC;
const static uint16_t NSEC3 = KNOT_RRTYPE_NSEC3;
uint8_t *p = key.data;
while(*p != 0) {
while(*p++ != 0) {
if (p - (uint8_t *)key.data >= key.len) {
return NULL;
}
}
// find the first double zero in the key; CACHE_KEY_DEF
const uint8_t *kd = key.data;
ssize_t i;
for (i = 2; !(kd[i - 1] == 0 && kd[i - 2] == 0); ++i) {
if (i >= key.len) return NULL;
}
if (p - (uint8_t *)key.data >= key.len) {
return NULL;
}
switch (*++p) {
// the next character can be used for classification
switch (kd[i]) {
case 'E':
return (p + 2 - (uint8_t *)key.data >= key.len ? NULL : (uint16_t *)(p + 1));
if (i + 1 + sizeof(uint16_t) > key.len) {
assert(!EINVAL);
return NULL;
}
return (uint16_t *)&kd[i + 1];
case '1':
return &NSEC1;
case '3':
......
......@@ -216,7 +216,7 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
switch (ret) {
case KNOT_EOK:
deleted_records++;
const uint16_t *entry_type = ret == KNOT_EOK ? kr_gc_key_consistent(**i) : NULL;
const uint16_t *entry_type = kr_gc_key_consistent(**i);
assert(entry_type != NULL);
rrtypelist_add(&deleted_rrtypes, *entry_type);
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment