unnecessary 'int' in s_conf.c
Rachel Llorenna
rachies at gmail.com
Fri Jan 7 19:01:43 EST 2005
>From ircd-hybrid-current, serial number 20041220_0. The 'int ret' is
unnecessary in s_conf.c:lookup_confhost (lines 2161-2205),
static void
lookup_confhost(struct ConfItem *conf)
{
struct AccessItem *aconf;
struct addrinfo hints, *res;
int ret;
aconf = map_to_conf(conf);
if (EmptyString(aconf->host) ||
EmptyString(aconf->user))
{
ilog(L_ERROR, "Host/server name error: (%s) (%s)",
aconf->host, conf->name);
return;
}
if (strchr(aconf->host, '*') ||
strchr(aconf->host, '?'))
return;
/* Do name lookup now on hostnames given and store the
* ip numbers in conf structure.
*/
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
/* Get us ready for a bind() and don't bother doing dns lookup */
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
if ((ret = irc_getaddrinfo(aconf->host, NULL, &hints, &res)))
{
conf_dns_lookup(aconf);
return;
}
assert(res != NULL);
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
aconf->ipnum.ss_len = res->ai_addrlen;
aconf->ipnum.ss.ss_family = res->ai_family;
irc_freeaddrinfo(res);
}
Note that 'ret' is not referenced beyond that single if statement.
Since the return value of irc_getaddrinfo is only used by that one
'if' statement, why not collapse that line to:
if (irc_getaddrinfo(aconf->host, NULL, &hints, &res)) ...
And remove the declaration of ret? This would only save a small and
insignificant amount of memory, but at least it doesn't come at the
cost of CPU cycles or other limited resources.
--
Regards,
Rachel Llorenna (frequency)
More information about the hybrid
mailing list