]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: Use istadv(const struct ist, const size_t) whenever possible
authorTim Duesterhus <tim@bastelstu.be>
Tue, 2 Mar 2021 17:57:27 +0000 (18:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Mar 2021 04:07:10 +0000 (05:07 +0100)
Refactoring performed with the following Coccinelle patch:

    @@
    struct ist i;
    expression e;
    @@

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

src/cache.c
src/flt_trace.c
src/htx.c
src/mux_h2.c

index acd68722b8e3d5870d6a3e56fbd65c81ebccb96a..12609e1ac0d0fe88ae80928db3a541b882a7c1a0 100644 (file)
@@ -620,8 +620,7 @@ cache_store_http_payload(struct stream *s, struct filter *filter, struct http_ms
 
                        case HTX_BLK_DATA:
                                v = htx_get_blk_value(htx, blk);
-                               v.ptr += offset;
-                               v.len -= offset;
+                               v = istadv(v, offset);
                                if (v.len > len)
                                        v.len = len;
 
index 206beda599491ab934aef1b87c4b268a6569a36f..424cd00143c69d0ab4d652fcc733f71e5275a439 100644 (file)
@@ -143,8 +143,7 @@ trace_htx_hexdump(struct htx *htx, unsigned int offset, unsigned int len)
                }
 
                v = htx_get_blk_value(htx, blk);
-               v.ptr += offset;
-               v.len -= offset;
+               v = istadv(v, offset);
                offset = 0;
 
                if (v.len > len)
index 6a4fe2d35190d52de72e2c43ef92b25fc4c949e3..774727b533e3db15e7d9cf133d6bc5a919522f5d 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -543,8 +543,7 @@ struct htx_blk *htx_add_data_atonce(struct htx *htx, struct ist data)
                blk = tailblk;
                goto end;
        }
-       data.ptr += len;
-       data.len -= len;
+       data = istadv(data, len);
 
   add_new_block:
        /* FIXME: check data.len (< 256MB) */
index 3810943c5578913ed7b3ff96047a48b0ad3c11ef..46940b40453b52d939d9057cc28ff76f65872280 100644 (file)
@@ -5361,16 +5361,14 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
                        if (len + 2 < uri.len && uri.ptr[len + 1] == '/' && uri.ptr[len + 2] == '/') {
                                /* make the uri start at the authority now */
                                scheme = ist2(uri.ptr, len);
-                               uri.ptr += len + 3;
-                               uri.len -= len + 3;
+                               uri = istadv(uri, len + 3);
 
                                /* find the auth part of the URI */
                                auth = ist2(uri.ptr, 0);
                                while (auth.len < uri.len && auth.ptr[auth.len] != '/')
                                        auth.len++;
 
-                               uri.ptr += auth.len;
-                               uri.len -= auth.len;
+                               uri = istadv(uri, auth.len);
                        }
                }