From: Sebastian Harl Date: Sun, 22 Jun 2014 11:28:46 +0000 (+0200) Subject: store_lookup: Simplified some internal checks. X-Git-Tag: sysdb-0.2.0~46 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6af8978bd0a03f024aba517495aa32c89de71e5c;p=sysdb.git store_lookup: Simplified some internal checks. --- diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 52739a6..e6e0a18 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -78,8 +78,6 @@ lookup_iter(sdb_store_base_t *obj, void *user_data) static int match_string(string_matcher_t *m, const char *name) { - assert(m); - if ((! m->name) && (! m->name_re)) return 1; @@ -99,7 +97,7 @@ match_logical(sdb_store_matcher_t *m, sdb_store_base_t *obj) { int status; - assert(m && obj); + assert((m->type == MATCHER_AND) || (m->type == MATCHER_OR)); assert(OP_M(m)->left && OP_M(m)->right); status = sdb_store_matcher_matches(OP_M(m)->left, obj); @@ -115,10 +113,8 @@ match_logical(sdb_store_matcher_t *m, sdb_store_base_t *obj) static int match_unary(sdb_store_matcher_t *m, sdb_store_base_t *obj) { - assert(m && obj); - assert(UOP_M(m)->op); - assert(m->type == MATCHER_NOT); + assert(UOP_M(m)->op); return !sdb_store_matcher_matches(UOP_M(m)->op, obj); } /* match_unary */ @@ -129,12 +125,8 @@ match_name(sdb_store_matcher_t *m, sdb_store_base_t *obj) sdb_llist_iter_t *iter = NULL; int status = 0; - assert(m && obj); assert(m->type == MATCHER_NAME); - if (obj->type != SDB_HOST) - return 0; - switch (NAME_M(m)->obj_type) { case SDB_HOST: return match_string(&NAME_M(m)->name, obj->super.name); @@ -164,12 +156,8 @@ match_attr(sdb_store_matcher_t *m, sdb_store_base_t *obj) sdb_llist_iter_t *iter = NULL; int status = 0; - assert(m && obj); assert(m->type == MATCHER_ATTR); - if (obj->type != SDB_HOST) - return 0; - iter = sdb_llist_get_iter(SDB_STORE_OBJ(obj)->attributes); while (sdb_llist_iter_has_next(iter)) { sdb_attribute_t *attr = SDB_ATTR(sdb_llist_iter_get_next(iter)); @@ -543,6 +531,9 @@ sdb_store_inv_matcher(sdb_store_matcher_t *m) int sdb_store_matcher_matches(sdb_store_matcher_t *m, sdb_store_base_t *obj) { + if (obj->type != SDB_HOST) + return 0; + /* "NULL" always matches */ if ((! m) || (! obj)) return 1;