From 0ec2844f4123c01908a1369266600d200356f043 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 9 Nov 2014 15:39:22 +0100 Subject: [PATCH] core: Improved style related to conditionals using many branches. --- src/core/data.c | 18 ++++++------------ src/core/store.c | 1 - src/core/store_lookup.c | 20 ++++++++------------ 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/core/data.c b/src/core/data.c index a954b3d..53cc888 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -714,18 +714,12 @@ sdb_data_expr_eval(int op, const sdb_data_t *d1, const sdb_data_t *d2, return 0; } switch (op) { - case SDB_DATA_CONCAT: - return data_concat(d1, d2, res); - case SDB_DATA_ADD: - return data_lin(d1, 1, d2, res); - case SDB_DATA_SUB: - return data_lin(d1, -1, d2, res); - case SDB_DATA_MUL: - return data_mul(d1, d2, res); - case SDB_DATA_DIV: - return data_div(d1, d2, res, NULL); - case SDB_DATA_MOD: - return data_div(d1, d2, NULL, res); + case SDB_DATA_CONCAT: return data_concat(d1, d2, res); + case SDB_DATA_ADD: return data_lin(d1, 1, d2, res); + case SDB_DATA_SUB: return data_lin(d1, -1, d2, res); + case SDB_DATA_MUL: return data_mul(d1, d2, res); + case SDB_DATA_DIV: return data_div(d1, d2, res, NULL); + case SDB_DATA_MOD: return data_div(d1, d2, NULL, res); } return -1; } /* sdb_data_expr_eval */ diff --git a/src/core/store.c b/src/core/store.c index d6ad01f..455e5a3 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -872,7 +872,6 @@ sdb_store_get_field(sdb_store_obj_t *obj, int field, sdb_data_t *res) tmp.data.array.length = obj->backends_num; tmp.data.array.values = obj->backends; return sdb_data_copy(res, &tmp); - break; } default: return -1; diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index b80a18f..e1e0396 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -107,18 +107,14 @@ match_cmp_value(int op, sdb_data_t *v1, sdb_data_t *v2, _Bool strcmp_fallback) if (status == INT_MAX) return 0; - else if (op == MATCHER_LT) - return status < 0; - else if (op == MATCHER_LE) - return status <= 0; - else if (op == MATCHER_EQ) - return status == 0; - else if (op == MATCHER_NE) - return status != 0; - else if (op == MATCHER_GE) - return status >= 0; - else if (op == MATCHER_GT) - return status > 0; + switch (op) { + case MATCHER_LT: return status < 0; + case MATCHER_LE: return status <= 0; + case MATCHER_EQ: return status == 0; + case MATCHER_NE: return status != 0; + case MATCHER_GE: return status >= 0; + case MATCHER_GT: return status > 0; + } return 0; } /* match_cmp_value */ -- 2.30.2