From: Alan T. DeKok Date: Fri, 2 Dec 2011 16:52:11 +0000 (+0100) Subject: Replace strlen with more efficient check X-Git-Tag: release_3_0_0_beta0~450 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=49e8f8c95b0098f0d6e8d0fe676681feedd47305;p=freeradius.git Replace strlen with more efficient check --- diff --git a/src/modules/rlm_sqlippool/rlm_sqlippool.c b/src/modules/rlm_sqlippool/rlm_sqlippool.c index 6c876e1..36c4e71 100644 --- a/src/modules/rlm_sqlippool/rlm_sqlippool.c +++ b/src/modules/rlm_sqlippool/rlm_sqlippool.c @@ -394,6 +394,8 @@ static int sqlippool_detach(void *instance) return 0; } +#define IS_EMPTY(_x) (!_x ||!*_x) + /* * Do any per-module initialization that is separate to each * configured instance of the module. e.g. set up connections @@ -425,8 +427,7 @@ static int sqlippool_instantiate(CONF_SECTION * conf, void ** instance) return -1; } - if ((data->sql_instance_name == NULL) || - (strlen(data->sql_instance_name) == 0)) { + if (IS_EMPTY(data->sql_instance_name)) { radlog(L_ERR, "rlm_sqlippool: the 'sql-instance-name' variable must be set."); sqlippool_detach(data); return -1; @@ -436,57 +437,49 @@ static int sqlippool_instantiate(CONF_SECTION * conf, void ** instance) * Check that all the queries are in place */ - if ((data->allocate_clear == NULL) || - (strlen(data->allocate_clear) == 0)) { + if (IS_EMPTY(data->allocate_clear)) { radlog(L_ERR, "rlm_sqlippool: the 'allocate-clear' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->allocate_find == NULL) || - (strlen(data->allocate_find) == 0)) { + if (IS_EMPTY(data->allocate_find)) { radlog(L_ERR, "rlm_sqlippool: the 'allocate_find' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->allocate_update == NULL) || - (strlen(data->allocate_update) == 0)) { + if (IS_EMPTY(data->allocate_update)) { radlog(L_ERR, "rlm_sqlippool: the 'allocate_update' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->start_update == NULL) || - (strlen(data->start_update) == 0)) { + if (IS_EMPTY(data->start_update)) { radlog(L_ERR, "rlm_sqlippool: the 'start-update' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->alive_update == NULL) || - (strlen(data->alive_update) == 0)) { + if (IS_EMPTY(data->alive_update)) { radlog(L_ERR, "rlm_sqlippool: the 'alive-update' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->stop_clear == NULL) || - (strlen(data->stop_clear) == 0)) { + if (IS_EMPTY(data->stop_clear)) { radlog(L_ERR, "rlm_sqlippool: the 'stop-clear' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->on_clear == NULL) || - (strlen(data->on_clear) == 0)) { + if (IS_EMPTY(data->on_clear)) { radlog(L_ERR, "rlm_sqlippool: the 'on-clear' statement must be set."); sqlippool_detach(data); return -1; } - if ((data->off_clear == NULL) || - (strlen(data->off_clear) == 0)) { + if (IS_EMPTY(data->off_clear)) { radlog(L_ERR, "rlm_sqlippool: the 'off-clear' statement must be set."); sqlippool_detach(data); return -1;