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 acd6872..12609e1 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 206beda..424cd00 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 6a4fe2d..774727b 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 3810943..46940b4 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);
                        }
                }