CLEANUP: Use istadv(const struct ist, const size_t) whenever possible

Refactoring performed with the following Coccinelle patch:

    @@
    struct ist i;
    expression e;
    @@

    - i.ptr += e;
    - i.len -= e;
    + i = istadv(i, e);
This commit is contained in:
Tim Duesterhus 2021-03-02 18:57:27 +01:00 committed by Willy Tarreau
parent 9f75ed114f
commit 154374cbc8
4 changed files with 5 additions and 10 deletions

View 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;

View 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)

View File

@ -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) */

View 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);
}
}