Skip to content

Commit

Permalink
Coverity CID #1258567
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Dec 15, 2014
1 parent f13a69f commit 60e42f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/lib/dict.c
Expand Up @@ -635,8 +635,9 @@ int dict_valid_name(char const *name)
return 0;
}

/*
* Add an attribute to the dictionary.
/** Add an attribute to the dictionary
*
* @return 0 on success -1 on failure.
*/
int dict_addattr(char const *name, int attr, unsigned int vendor, PW_TYPE type,
ATTR_FLAGS flags)
Expand Down
17 changes: 8 additions & 9 deletions src/modules/rlm_sqlcounter/rlm_sqlcounter.c
Expand Up @@ -384,29 +384,28 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
*/
rad_assert(inst->counter_name && *inst->counter_name);
memset(&flags, 0, sizeof(flags));
dict_addattr(inst->counter_name, -1, 0, PW_TYPE_INTEGER64, flags);
da = dict_attrbyname(inst->counter_name);
if (!da) {
cf_log_err_cs(conf, "Failed to create counter attribute %s", inst->counter_name);
if ((dict_addattr(inst->counter_name, -1, 0, PW_TYPE_INTEGER64, flags) < 0) ||
!(da = dict_attrbyname(inst->counter_name))) {
cf_log_err_cs(conf, "Failed to create counter attribute %s: %s", inst->counter_name, fr_strerror());
return -1;
}

inst->dict_attr = da;

/*
* Create a new attribute for the check item.
*/
rad_assert(inst->limit_name && *inst->limit_name);
dict_addattr(inst->limit_name, -1, 0, PW_TYPE_INTEGER64, flags);
da = dict_attrbyname(inst->limit_name);
if (!da) {
cf_log_err_cs(conf, "Failed to create check attribute %s", inst->limit_name);
if ((dict_addattr(inst->limit_name, -1, 0, PW_TYPE_INTEGER64, flags) < 0) ||
!(da = dict_attrbyname(inst->limit_name))) {
cf_log_err_cs(conf, "Failed to create check attribute %s: %s", inst->limit_name, fr_strerror());
return -1;
}

now = time(NULL);
inst->reset_time = 0;

if (find_next_reset(inst,now) == -1) {
if (find_next_reset(inst, now) == -1) {
cf_log_err_cs(conf, "Invalid reset '%s'", inst->reset);
return -1;
}
Expand Down

0 comments on commit 60e42f2

Please sign in to comment.