Commit 7eaf8463 authored by Daniel Salzman's avatar Daniel Salzman

namedb: tiny cleanup

parent 22c54183
......@@ -33,15 +33,15 @@ enum {
// Do not change these mappings if you want backwards compatibility.
static const uint8_t event_id_to_key[ZONE_EVENT_COUNT] = {
[ZONE_EVENT_REFRESH] = KEY_REFRESH,
[ZONE_EVENT_EXPIRE] = KEY_EXPIRE,
[ZONE_EVENT_FLUSH] = KEY_FLUSH
[ZONE_EVENT_REFRESH] = KEY_REFRESH,
[ZONE_EVENT_EXPIRE] = KEY_EXPIRE,
[ZONE_EVENT_FLUSH] = KEY_FLUSH
};
static const int key_to_event_id[PERSISTENT_EVENT_COUNT + 1] = {
[KEY_REFRESH] = ZONE_EVENT_REFRESH,
[KEY_EXPIRE] = ZONE_EVENT_EXPIRE,
[KEY_FLUSH] = ZONE_EVENT_FLUSH
[KEY_REFRESH] = ZONE_EVENT_REFRESH,
[KEY_EXPIRE] = ZONE_EVENT_EXPIRE,
[KEY_FLUSH] = ZONE_EVENT_FLUSH
};
static bool known_event_key(uint8_t key)
......@@ -128,18 +128,18 @@ static int read_timers(namedb_txn_t *txn, const zone_t *zone, time_t *timers)
int open_timers_db(const char *storage, namedb_t **db_ptr)
{
if (!storage || !db_ptr) {
if (storage == NULL || db_ptr == NULL) {
return KNOT_EINVAL;
}
struct namedb_lmdb_opts opts = NAMEDB_LMDB_OPTS_INITIALIZER;
const namedb_api_t *db_api = namedb_lmdb_api();
if (!db_api) {
if (db_api == NULL) {
return KNOT_ENOTSUP;
}
opts.path = sprintf_alloc("%s/timers", storage);
if (!opts.path) {
if (opts.path == NULL) {
return KNOT_ENOMEM;
}
......@@ -152,7 +152,7 @@ int open_timers_db(const char *storage, namedb_t **db_ptr)
void close_timers_db(namedb_t *timer_db)
{
if (!timer_db) {
if (timer_db == NULL) {
return;
}
......
......@@ -166,7 +166,6 @@ static int init(namedb_t **db_ptr, mm_ctx_t *mm, void *arg)
return KNOT_EINVAL;
}
int ret = KNOT_EOK;
struct lmdb_env *env = mm_alloc(mm, sizeof(struct lmdb_env));
if (env == NULL) {
return KNOT_ENOMEM;
......@@ -176,9 +175,9 @@ static int init(namedb_t **db_ptr, mm_ctx_t *mm, void *arg)
env->pool = mm;
/* Open new environment. */
struct lmdb_env *old_env = (*db_ptr);
struct lmdb_env *old_env = *db_ptr;
if (old_env == NULL) {
ret = dbase_open_env(env, (struct namedb_lmdb_opts *)arg);
int ret = dbase_open_env(env, (struct namedb_lmdb_opts *)arg);
if (ret != KNOT_EOK) {
mm_free(mm, env);
return ret;
......@@ -190,7 +189,7 @@ static int init(namedb_t **db_ptr, mm_ctx_t *mm, void *arg)
}
/* Open the database. */
ret = dbase_open(env, (struct namedb_lmdb_opts *)arg);
int ret = dbase_open(env, (struct namedb_lmdb_opts *)arg);
if (ret != KNOT_EOK) {
mm_free(mm, env);
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment