]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse: Simplication.
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 11 Jan 2019 10:47:12 +0000 (11:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2019 13:26:21 +0000 (14:26 +0100)
Make init_peers_frontend() be callable without having to check if
there is something to do or not.

May be backported to 1.5 and newer.

src/cfgparse.c

index a391b8235310196293fee67a2694d36c6f048792..e5831a5dc9d82b8775f157b6b685d2119d074c16 100644 (file)
@@ -491,6 +491,10 @@ static int init_peers_frontend(const char *file, int linenum,
 {
        struct proxy *p;
 
+       if (peers->peers_fe)
+               /* Nothing to do */
+               return 0;
+
        p = calloc(1, sizeof *p);
        if (!p) {
                ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
@@ -658,8 +662,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                /* Current is local peer, it define a frontend */
                newpeer->local = 1;
 
-               if (!curpeers->peers_fe &&
-                   init_peers_frontend(file, linenum, args[1], curpeers) != 0) {
+               if (init_peers_frontend(file, linenum, args[1], curpeers) != 0) {
                                ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
                                err_code |= ERR_ALERT | ERR_ABORT;
                                goto out;