From c1907b60719f4e9a8e5b29aef5c8e25d62f4cde2 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 3 Sep 2015 00:13:25 +0200 Subject: [PATCH] Remove unused sdb_store_expr_iterable(). --- src/core/store_expr.c | 38 ----------------------------------- src/include/core/store.h | 13 +----------- t/unit/core/store_expr_test.c | 11 ++-------- 3 files changed, 3 insertions(+), 59 deletions(-) diff --git a/src/core/store_expr.c b/src/core/store_expr.c index 5e15f53..642255e 100644 --- a/src/core/store_expr.c +++ b/src/core/store_expr.c @@ -263,44 +263,6 @@ sdb_store_expr_eval(sdb_store_expr_t *expr, sdb_store_obj_t *obj, return status; } /* sdb_store_expr_eval */ -bool -sdb_store_expr_iterable(sdb_store_expr_t *expr, int context) -{ - if (expr->type == TYPED_EXPR) { - if ((context != SDB_HOST) && (context != SDB_SERVICE) - && (context != SDB_METRIC)) - return 0; - if (context == expr->data.data.integer) - return 0; - if ((expr->data.data.integer != SDB_SERVICE) - && (expr->data.data.integer != SDB_METRIC) - && (expr->data.data.integer != SDB_ATTRIBUTE)) - return 0; - if ((context == SDB_SERVICE) - && (expr->data.data.integer == SDB_METRIC)) - return 0; - else if ((context == SDB_METRIC) - && (expr->data.data.integer == SDB_SERVICE)) - return 0; - return 1; - } - else if (expr->type == FIELD_VALUE) { - if ((context != SDB_HOST) && (context != SDB_SERVICE) - && (context != SDB_METRIC) && (context != SDB_ATTRIBUTE)) - return 0; - if (expr->data.data.integer == SDB_FIELD_BACKEND) - return 1; - else if (expr->data.data.integer == SDB_FIELD_VALUE) - /* we don't current support this just like when using - * the attribute[] syntax */ - return 0; - } - else if (! expr->type) { - return !!(expr->data.type & SDB_TYPE_ARRAY); - } - return 0; -} /* sdb_store_expr_iterable */ - sdb_store_expr_iter_t * sdb_store_expr_iter(sdb_store_expr_t *expr, sdb_store_obj_t *obj, sdb_store_matcher_t *filter) diff --git a/src/include/core/store.h b/src/include/core/store.h index 28b257e..090b76b 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -130,8 +130,7 @@ typedef struct sdb_store_expr sdb_store_expr_t; #define SDB_STORE_EXPR(obj) ((sdb_store_expr_t *)(obj)) /* - * An expression iterator iterates over the values of an iterable expression - * (see sdb_store_expr_iterable). + * An expression iterator iterates over the values of an iterable expression. */ struct sdb_store_expr_iter; typedef struct sdb_store_expr_iter sdb_store_expr_iter_t; @@ -512,20 +511,10 @@ int sdb_store_expr_eval(sdb_store_expr_t *expr, sdb_store_obj_t *obj, sdb_data_t *res, sdb_store_matcher_t *filter); -/* - * sdb_store_expr_iterable: - * Check whether an expression, evaluated in the specified context (HOST, - * SERVICE, METRIC) is iterable, that is, if it may evaluate to multiple - * values. - */ -bool -sdb_store_expr_iterable(sdb_store_expr_t *expr, int context); - /* * sdb_store_expr_iter: * Iterate over the elements of an iterable expression. sdb_store_expr_iter * returns NULL if the expression is not iterable (for the specified object). - * See also sdb_store_expr_iterable. * * sdb_store_expr_iter_get_next returns NULL if there is no next element. */ diff --git a/t/unit/core/store_expr_test.c b/t/unit/core/store_expr_test.c index 303a921..d11452a 100644 --- a/t/unit/core/store_expr_test.c +++ b/t/unit/core/store_expr_test.c @@ -560,7 +560,6 @@ START_TEST(test_expr_iter) sdb_store_matcher_t *filter = NULL; int context = SDB_HOST; - bool iterable; sdb_store_expr_iter_t *iter; size_t i; @@ -587,19 +586,13 @@ START_TEST(test_expr_iter) ck_assert(filter != NULL); } - iterable = sdb_store_expr_iterable(&expr_iter_data[_i].expr, context); - fail_unless(iterable == expr_iter_data[_i].iterable, - "%s expression not iterable in %s context", - EXPR_TO_STRING(&expr_iter_data[_i].expr), - SDB_STORE_TYPE_TO_NAME(context)); - iter = sdb_store_expr_iter(&expr_iter_data[_i].expr, obj, filter); - fail_unless((iter != NULL) == iterable, + fail_unless((iter != NULL) == expr_iter_data[_i].iterable, "sdb_store_expr_iter(%s expression, %s, %s) = %s; expected: %s", EXPR_TO_STRING(&expr_iter_data[_i].expr), obj ? SDB_STORE_TYPE_TO_NAME(obj->type) : "", expr_iter_data[_i].filter, iter ? "" : "NULL", - iterable ? "" : "NULL"); + expr_iter_data[_i].iterable ? "" : "NULL"); /* the iterator will keep a reference */ sdb_object_deref(SDB_OBJ(obj)); obj = NULL; -- 2.30.2