mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 06:40:59 +01:00
CLEANUP: Apply ist.cocci
Make use of the new rules to use `istend()`.
This commit is contained in:
parent
958f50454a
commit
4c8f75fc31
4
src/h1.c
4
src/h1.c
@ -110,7 +110,7 @@ int h1_parse_xfer_enc_header(struct h1m *h1m, struct ist value)
|
|||||||
h1m->flags |= H1_MF_XFER_ENC;
|
h1m->flags |= H1_MF_XFER_ENC;
|
||||||
|
|
||||||
word.ptr = value.ptr - 1; // -1 for next loop's pre-increment
|
word.ptr = value.ptr - 1; // -1 for next loop's pre-increment
|
||||||
e = value.ptr + value.len;
|
e = istend(value);
|
||||||
|
|
||||||
while (++word.ptr < e) {
|
while (++word.ptr < e) {
|
||||||
/* skip leading delimiter and blanks */
|
/* skip leading delimiter and blanks */
|
||||||
@ -229,7 +229,7 @@ void h1_parse_upgrade_header(struct h1m *h1m, struct ist value)
|
|||||||
h1m->flags &= ~H1_MF_UPG_WEBSOCKET;
|
h1m->flags &= ~H1_MF_UPG_WEBSOCKET;
|
||||||
|
|
||||||
word.ptr = value.ptr - 1; // -1 for next loop's pre-increment
|
word.ptr = value.ptr - 1; // -1 for next loop's pre-increment
|
||||||
e = value.ptr + value.len;
|
e = istend(value);
|
||||||
|
|
||||||
while (++word.ptr < e) {
|
while (++word.ptr < e) {
|
||||||
/* skip leading delimiter and blanks */
|
/* skip leading delimiter and blanks */
|
||||||
|
|||||||
2
src/h2.c
2
src/h2.c
@ -62,7 +62,7 @@ static int has_forbidden_char(const struct ist ist, const char *start)
|
|||||||
(1U << (uint8_t)*start) & ((1<<13) | (1<<10) | (1<<0)))
|
(1U << (uint8_t)*start) & ((1<<13) | (1<<10) | (1<<0)))
|
||||||
return 1;
|
return 1;
|
||||||
start++;
|
start++;
|
||||||
} while (start < ist.ptr + ist.len);
|
} while (start < istend(ist));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4750,7 +4750,7 @@ static int hlua_applet_http_new(lua_State *L, struct appctx *ctx)
|
|||||||
char *p, *q, *end;
|
char *p, *q, *end;
|
||||||
|
|
||||||
p = path.ptr;
|
p = path.ptr;
|
||||||
end = path.ptr + path.len;
|
end = istend(path);
|
||||||
q = p;
|
q = p;
|
||||||
while (q < end && *q != '?')
|
while (q < end && *q != '?')
|
||||||
q++;
|
q++;
|
||||||
|
|||||||
@ -195,7 +195,8 @@ static int __http_find_header(const struct htx *htx, const void *pattern, struct
|
|||||||
if (istlen(n) < istlen(name))
|
if (istlen(n) < istlen(name))
|
||||||
goto next_blk;
|
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))
|
if (!isteqi(n, name))
|
||||||
goto next_blk;
|
goto next_blk;
|
||||||
break;
|
break;
|
||||||
@ -219,8 +220,9 @@ static int __http_find_header(const struct htx *htx, const void *pattern, struct
|
|||||||
ctx->lws_before++;
|
ctx->lws_before++;
|
||||||
}
|
}
|
||||||
if (!(flags & HTTP_FIND_FL_FULL))
|
if (!(flags & HTTP_FIND_FL_FULL))
|
||||||
v.len = http_find_hdr_value_end(v.ptr, v.ptr + v.len) - v.ptr;
|
v.len = http_find_hdr_value_end(v.ptr, istend(v)) - v.ptr;
|
||||||
while (v.len && HTTP_IS_LWS(*(v.ptr + v.len - 1))) {
|
|
||||||
|
while (v.len && HTTP_IS_LWS(*(istend(v) - 1))) {
|
||||||
v.len--;
|
v.len--;
|
||||||
ctx->lws_after++;
|
ctx->lws_after++;
|
||||||
}
|
}
|
||||||
@ -710,7 +712,7 @@ int http_update_authority(struct htx *htx, struct htx_sl *sl, const struct ist h
|
|||||||
|
|
||||||
chunk_memcat(temp, uri.ptr, authority.ptr - uri.ptr);
|
chunk_memcat(temp, uri.ptr, authority.ptr - uri.ptr);
|
||||||
chunk_memcat(temp, host.ptr, host.len);
|
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 */
|
uri = ist2(temp->area + meth.len + vsn.len, host.len + uri.len - authority.len); /* uri */
|
||||||
|
|
||||||
return http_replace_stline(htx, meth, uri, vsn);
|
return http_replace_stline(htx, meth, uri, vsn);
|
||||||
@ -917,7 +919,7 @@ int http_str_to_htx(struct buffer *buf, struct ist raw, char **errmsg)
|
|||||||
|
|
||||||
h1m_init_res(&h1m);
|
h1m_init_res(&h1m);
|
||||||
h1m.flags |= H1_MF_NO_PHDR;
|
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);
|
hdrs, sizeof(hdrs)/sizeof(hdrs[0]), &h1m, &h1sl);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
memprintf(errmsg, "unabled to parse headers (error offset: %d)", h1m.err_pos);
|
memprintf(errmsg, "unabled to parse headers (error offset: %d)", h1m.err_pos);
|
||||||
|
|||||||
11
src/htx.c
11
src/htx.c
@ -601,11 +601,13 @@ struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk,
|
|||||||
if (delta <= 0) {
|
if (delta <= 0) {
|
||||||
/* compression: copy new data first then move the end */
|
/* compression: copy new data first then move the end */
|
||||||
memcpy(old.ptr, new.ptr, new.len);
|
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 {
|
else {
|
||||||
/* expansion: move the end first then copy new data */
|
/* 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);
|
memcpy(old.ptr, new.ptr, new.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +631,7 @@ struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk,
|
|||||||
ptr += new.len;
|
ptr += new.len;
|
||||||
|
|
||||||
/* Copy value after old part, if any */
|
/* 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 */
|
/* set the new block size and update HTX message */
|
||||||
htx_set_blk_value_len(blk, v.len + delta);
|
htx_set_blk_value_len(blk, v.len + delta);
|
||||||
@ -654,7 +656,8 @@ struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk,
|
|||||||
|
|
||||||
/* move the end first and copy new data
|
/* 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);
|
memcpy(old.ptr + offset, new.ptr, new.len);
|
||||||
}
|
}
|
||||||
return blk;
|
return blk;
|
||||||
|
|||||||
@ -1818,7 +1818,7 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect_http(struct check *check, struct tcp
|
|||||||
case TCPCHK_EXPT_FL_HTTP_HVAL_END:
|
case TCPCHK_EXPT_FL_HTTP_HVAL_END:
|
||||||
if (istlen(value) < istlen(vpat))
|
if (istlen(value) < istlen(vpat))
|
||||||
break;
|
break;
|
||||||
value = ist2(istptr(value) + istlen(value) - istlen(vpat), istlen(vpat));
|
value = ist2(istend(value) - istlen(vpat), istlen(vpat));
|
||||||
if (isteq(value, vpat)) {
|
if (isteq(value, vpat)) {
|
||||||
match = 1;
|
match = 1;
|
||||||
goto end_of_match;
|
goto end_of_match;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user