From: Jorge Pereira Date: Wed, 24 Jun 2015 19:57:55 +0000 (-0300) Subject: avoid strings replication X-Git-Tag: release_3_0_9~81^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4d23902ac6de1b2df8a46854e1419ba08c4584a;p=thirdparty%2Ffreeradius-server.git avoid strings replication --- diff --git a/src/main/conffile.c b/src/main/conffile.c index fba97b24142..8b3ace0799b 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -1366,6 +1366,7 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d CONF_PAIR *cp = NULL; fr_ipaddr_t *ipaddr; char buffer[8192]; + CONF_ITEM *c_item = &cs->item; if (!cs) return -1; @@ -1385,7 +1386,7 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d * Everything except templates must have a base type. */ if (!(type & 0xff) && !tmpl) { - cf_log_err(&(cs->item), "Configuration item '%s' must have a data type", name); + cf_log_err(c_item, "Configuration item '%s' must have a data type", name); return -1; } @@ -1409,6 +1410,7 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d CONF_PAIR *next = cp; value = cp->value; cp->parsed = true; + c_item = &cp->item; /* * @fixme We should actually validate @@ -1422,11 +1424,8 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d if (!value) { if (required) { is_required: - if (!cp) { - cf_log_err(&(cs->item), "Configuration item '%s' must have a value", name); - } else { - cf_log_err(&(cp->item), "Configuration item '%s' must have a value", name); - } + cf_log_err(c_item, "Configuration item '%s' must have a value", name); + return -1; } return rcode; @@ -1434,18 +1433,16 @@ int cf_item_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d if ((value[0] == '\0') && cant_be_empty) { cant_be_empty: - if (!cp) { - cf_log_err(&(cs->item), "Configuration item '%s' must not be empty (zero length)", name); - if (!required) cf_log_err(&(cs->item), "Comment item to silence this message"); - } else { - cf_log_err(&(cp->item), "Configuration item '%s' must not be empty (zero length)", name); - if (!required) cf_log_err(&(cp->item), "Comment item to silence this message"); - } + cf_log_err(c_item, "Configuration item '%s' must not be empty (zero length)", name); + + if (!required) + cf_log_err(c_item, "Comment item to silence this message"); + return -1; } if (deprecated) { - cf_log_err(&(cs->item), "Configuration item \"%s\" is deprecated", name); + cf_log_err(c_item, "Configuration item \"%s\" is deprecated", name); return -2; }