From: Willy Tarreau Date: Tue, 26 May 2015 09:35:41 +0000 (+0200) Subject: MINOR: proxy: simply ignore duplicates in proxy name lookups X-Git-Tag: v1.6-dev2~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c739aa85e847e978928c54ac29df22d00ab040c2;p=thirdparty%2Fhaproxy.git MINOR: proxy: simply ignore duplicates in proxy name lookups Now that we can't have duplicate proxies with similar capabilities, we can remove some painful check. The first one is the check that made the lookup function return NULL when a duplicate is found, as it prevented it from being used in the config parser to detect duplicates. --- diff --git a/src/proxy.c b/src/proxy.c index 56af7820b8..5c8e26d968 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -388,14 +388,13 @@ struct proxy *findproxy_mode(const char *name, int mode, int cap) { return target; } -/* Returns a pointer to the proxy matching either name , or id if - * begins with a '#'. NULL is returned if no match is found, as well as - * if multiple matches are found (eg: too large capabilities mask). If - * is non-zero, it only considers proxies having a table. +/* Returns a pointer to the first proxy matching either name , or id + * if begins with a '#'. NULL is returned if no match is found. + * If
is non-zero, it only considers proxies having a table. */ struct proxy *proxy_find_by_name(const char *name, int cap, int table) { - struct proxy *curproxy, *target = NULL; + struct proxy *curproxy; int pid = -1; if (*name == '#') { @@ -415,10 +414,7 @@ struct proxy *proxy_find_by_name(const char *name, int cap, int table) if (table && !curproxy->table.size) continue; - if (target) - return NULL; - - target = curproxy; + return curproxy; } } else { @@ -436,13 +432,10 @@ struct proxy *proxy_find_by_name(const char *name, int cap, int table) if (table && !curproxy->table.size) continue; - if (target) - return NULL; - - target = curproxy; + return curproxy; } } - return target; + return NULL; } /*