CLEANUP: Apply ist.cocci
Make use of the new rules to use `istend()`.
diff --git a/src/h1.c b/src/h1.c
index e0ba8d7..99b9c29 100644
--- a/src/h1.c
+++ b/src/h1.c
@@ -110,7 +110,7 @@
h1m->flags |= H1_MF_XFER_ENC;
word.ptr = value.ptr - 1; // -1 for next loop's pre-increment
- e = value.ptr + value.len;
+ e = istend(value);
while (++word.ptr < e) {
/* skip leading delimiter and blanks */
@@ -229,7 +229,7 @@
h1m->flags &= ~H1_MF_UPG_WEBSOCKET;
word.ptr = value.ptr - 1; // -1 for next loop's pre-increment
- e = value.ptr + value.len;
+ e = istend(value);
while (++word.ptr < e) {
/* skip leading delimiter and blanks */
diff --git a/src/h2.c b/src/h2.c
index dd1f7d9..49a1252 100644
--- a/src/h2.c
+++ b/src/h2.c
@@ -62,7 +62,7 @@
(1U << (uint8_t)*start) & ((1<<13) | (1<<10) | (1<<0)))
return 1;
start++;
- } while (start < ist.ptr + ist.len);
+ } while (start < istend(ist));
return 0;
}
diff --git a/src/hlua.c b/src/hlua.c
index e9d4391..086a8e0 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -4750,7 +4750,7 @@
char *p, *q, *end;
p = path.ptr;
- end = path.ptr + path.len;
+ end = istend(path);
q = p;
while (q < end && *q != '?')
q++;
diff --git a/src/http_htx.c b/src/http_htx.c
index 8028cfc..6b06336 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -195,7 +195,8 @@
if (istlen(n) < istlen(name))
goto next_blk;
- n = ist2(istptr(n) + istlen(n) - istlen(name), istlen(name));
+ n = ist2(istend(n) - istlen(name),
+ istlen(name));
if (!isteqi(n, name))
goto next_blk;
break;
@@ -219,8 +220,9 @@
ctx->lws_before++;
}
if (!(flags & HTTP_FIND_FL_FULL))
- v.len = http_find_hdr_value_end(v.ptr, v.ptr + v.len) - v.ptr;
- while (v.len && HTTP_IS_LWS(*(v.ptr + v.len - 1))) {
+ v.len = http_find_hdr_value_end(v.ptr, istend(v)) - v.ptr;
+
+ while (v.len && HTTP_IS_LWS(*(istend(v) - 1))) {
v.len--;
ctx->lws_after++;
}
@@ -710,7 +712,7 @@
chunk_memcat(temp, uri.ptr, authority.ptr - uri.ptr);
chunk_memcat(temp, host.ptr, host.len);
- chunk_memcat(temp, authority.ptr + authority.len, uri.ptr + uri.len - (authority.ptr + authority.len));
+ chunk_memcat(temp, istend(authority), istend(uri) - istend(authority));
uri = ist2(temp->area + meth.len + vsn.len, host.len + uri.len - authority.len); /* uri */
return http_replace_stline(htx, meth, uri, vsn);
@@ -917,7 +919,7 @@
h1m_init_res(&h1m);
h1m.flags |= H1_MF_NO_PHDR;
- ret = h1_headers_to_hdr_list(raw.ptr, raw.ptr + raw.len,
+ ret = h1_headers_to_hdr_list(raw.ptr, istend(raw),
hdrs, sizeof(hdrs)/sizeof(hdrs[0]), &h1m, &h1sl);
if (ret <= 0) {
memprintf(errmsg, "unabled to parse headers (error offset: %d)", h1m.err_pos);
diff --git a/src/htx.c b/src/htx.c
index 8c6e368..940989c 100644
--- a/src/htx.c
+++ b/src/htx.c
@@ -601,11 +601,13 @@
if (delta <= 0) {
/* compression: copy new data first then move the end */
memcpy(old.ptr, new.ptr, new.len);
- memmove(old.ptr + new.len, old.ptr + old.len, (v.ptr + v.len) - (old.ptr + old.len));
+ memmove(old.ptr + new.len, istend(old),
+ istend(v) - istend(old));
}
else {
/* expansion: move the end first then copy new data */
- memmove(old.ptr + new.len, old.ptr + old.len, (v.ptr + v.len) - (old.ptr + old.len));
+ memmove(old.ptr + new.len, istend(old),
+ istend(v) - istend(old));
memcpy(old.ptr, new.ptr, new.len);
}
@@ -629,7 +631,7 @@
ptr += new.len;
/* Copy value after old part, if any */
- memcpy(ptr, old.ptr + old.len, (v.ptr + v.len) - (old.ptr + old.len));
+ memcpy(ptr, istend(old), istend(v) - istend(old));
/* set the new block size and update HTX message */
htx_set_blk_value_len(blk, v.len + delta);
@@ -654,7 +656,8 @@
/* move the end first and copy new data
*/
- memmove(old.ptr + offset + new.len, old.ptr + offset + old.len, (v.ptr + v.len) - (old.ptr + old.len));
+ memmove(old.ptr + offset + new.len, old.ptr + offset + old.len,
+ istend(v) - istend(old));
memcpy(old.ptr + offset, new.ptr, new.len);
}
return blk;
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index 14f83ea..bf497fe 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -1818,7 +1818,7 @@
case TCPCHK_EXPT_FL_HTTP_HVAL_END:
if (istlen(value) < istlen(vpat))
break;
- value = ist2(istptr(value) + istlen(value) - istlen(vpat), istlen(vpat));
+ value = ist2(istend(value) - istlen(vpat), istlen(vpat));
if (isteq(value, vpat)) {
match = 1;
goto end_of_match;