]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: fcgi: Use `istadv()` in `fcgi_strm_send_params`
authorTim Duesterhus <tim@bastelstu.be>
Fri, 4 Mar 2022 23:52:45 +0000 (00:52 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Mar 2022 06:51:27 +0000 (07:51 +0100)
Found manually, while creating the previous commits to turn `struct proxy`
members into ists.

There is an existing Coccinelle rule to replace this pattern by `istadv()` in
`ist.cocci`:

    @@
    struct ist i;
    expression e;
    @@

    - i.ptr += e;
    - i.len -= e;
    + i = istadv(i, e);

But apparently it is not smart enough to match ists that are stored in another
struct. It would be useful to make the existing rule more generic, so that it
might catch similar cases in the future.

src/mux_fcgi.c

index 0a8679019a255b7e8ef3ce6d6421b498d2f81dbb..ef264edaef329a29e4ed61638d48efa42f943d71 100644 (file)
@@ -1980,8 +1980,7 @@ static size_t fcgi_strm_send_params(struct fcgi_conn *fconn, struct fcgi_strm *f
                                p.v = htx_get_blk_value(htx, blk);
 
                                if (istmatch(p.n, ist(":fcgi-"))) {
-                                       p.n.ptr += 6;
-                                       p.n.len -= 6;
+                                       p.n = istadv(p.n, 6);
                                        if (isteq(p.n, ist("gateway_interface")))
                                                params.mask |= FCGI_SP_CGI_GATEWAY;
                                        else if (isteq(p.n, ist("document_root"))) {