]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: peers/cli: stop misusing the appctx local variable
authorWilly Tarreau <w@1wt.eu>
Tue, 31 May 2022 06:53:25 +0000 (08:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 May 2022 06:53:25 +0000 (08:53 +0200)
In the context of a CLI command, it's particularly not welcome to use
an "appctx" variable that is not the current one. In addition it was
created for use at exactly 6 places in 2 lines. Let's just remove it
and stick to peer->appctx which is used elsewhere in the function and
is unambiguous.

src/peers.c

index 6dfa35f8e41f68bcd08dd5c1ae4e7cf2fa63ee75..ae829e2a717b4ef004b5127115edbc628cce0e86 100644 (file)
@@ -3777,7 +3777,6 @@ static int peers_dump_peer(struct buffer *msg, struct stconn *sc, struct peer *p
        char pn[INET6_ADDRSTRLEN];
        struct stconn *peer_cs;
        struct stream *peer_s;
-       struct appctx *appctx;
        struct shared_table *st;
 
        addr_to_str(&peer->addr, pn, sizeof pn);
@@ -3810,12 +3809,12 @@ static int peers_dump_peer(struct buffer *msg, struct stconn *sc, struct peer *p
 
        chunk_appendf(&trash, "        flags=0x%x", peer->flags);
 
-       appctx = peer->appctx;
-       if (!appctx)
+       if (!peer->appctx)
                goto table_info;
 
-       chunk_appendf(&trash, " appctx:%p st0=%d st1=%d task_calls=%u", appctx, appctx->st0, appctx->st1,
-                                                                       appctx->t ? appctx->t->calls : 0);
+       chunk_appendf(&trash, " appctx:%p st0=%d st1=%d task_calls=%u",
+                     peer->appctx, peer->appctx->st0, peer->appctx->st1,
+                     peer->appctx->t ? peer->appctx->t->calls : 0);
 
        peer_cs = appctx_sc(peer->appctx);
        peer_s = __sc_strm(peer_cs);