CLEANUP: Reapply ist.cocci with --include-headers-for-types --recursive-includes

Previous uses of `ist.cocci` did not add `--include-headers-for-types` and
`--recursive-includes` preventing Coccinelle seeing `struct ist` members of
other structs.

Reapply the patch with proper flags to further clean up the use of the ist API.

The command used was:

    spatch -sp_file dev/coccinelle/ist.cocci -in_place --include-headers --include-headers-for-types --recursive-includes --dir src/
This commit is contained in:
Tim Duesterhus 2022-03-15 13:11:06 +01:00 committed by Willy Tarreau
parent 99f47377c8
commit 7750850594
12 changed files with 30 additions and 38 deletions

View File

@ -626,7 +626,7 @@ cache_store_http_payload(struct stream *s, struct filter *filter, struct http_ms
info = (type << 28) + v.len;
chunk_memcat(&trash, (char *)&info, sizeof(info));
chunk_memcat(&trash, v.ptr, v.len);
chunk_istcat(&trash, v);
to_forward += v.len;
len -= v.len;
break;

View File

@ -197,10 +197,8 @@ size_t fcgi_decode_param(const struct buffer *in, size_t o, struct fcgi_param *p
if (data < nlen + vlen)
return 0;
p->n.ptr = b_peek(in, o);
p->n.len = nlen;
p->v.ptr = b_peek(in, o+nlen);
p->v.len = vlen;
p->n = ist2(b_peek(in, o), nlen);
p->v = ist2(b_peek(in, o + nlen), vlen);
len += nlen + vlen;
return len;
@ -254,10 +252,8 @@ size_t fcgi_aligned_decode_param(const struct buffer *in, size_t o, struct fcgi_
if (data < nlen + vlen)
return 0;
p->n.ptr = in->area + o;
p->n.len = nlen;
p->v.ptr = in->area + o + nlen;
p->v.len = vlen;
p->n = ist2(in->area + o, nlen);
p->v = ist2(in->area + o + nlen, vlen);
len += nlen + vlen;
return len;

View File

@ -400,26 +400,26 @@ select_compression_request_header(struct comp_state *st, struct stream *s, struc
qval = ctx.value.ptr + toklen;
while (1) {
while (qval < ctx.value.ptr + ctx.value.len && HTTP_IS_LWS(*qval))
while (qval < istend(ctx.value) && HTTP_IS_LWS(*qval))
qval++;
if (qval >= ctx.value.ptr + ctx.value.len || *qval != ';') {
if (qval >= istend(ctx.value) || *qval != ';') {
qval = NULL;
break;
}
qval++;
while (qval < ctx.value.ptr + ctx.value.len && HTTP_IS_LWS(*qval))
while (qval < istend(ctx.value) && HTTP_IS_LWS(*qval))
qval++;
if (qval >= ctx.value.ptr + ctx.value.len) {
if (qval >= istend(ctx.value)) {
qval = NULL;
break;
}
if (strncmp(qval, "q=", MIN(ctx.value.ptr + ctx.value.len - qval, 2)) == 0)
if (strncmp(qval, "q=", MIN(istend(ctx.value) - qval, 2)) == 0)
break;
while (qval < ctx.value.ptr + ctx.value.len && *qval != ';')
while (qval < istend(ctx.value) && *qval != ';')
qval++;
}

View File

@ -428,8 +428,7 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
http_msg_req09_uri_e:
sl.rq.u.len = ptr - sl.rq.u.ptr;
http_msg_req09_ver:
sl.rq.v.ptr = ptr;
sl.rq.v.len = 0;
sl.rq.v = ist2(ptr, 0);
goto http_msg_rqline_eol;
}
state = H1_MSG_RQMETH;
@ -659,8 +658,7 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
sl.st.c.len = ptr - sl.st.c.ptr;
http_msg_rsp_reason:
sl.st.r.ptr = ptr;
sl.st.r.len = 0;
sl.st.r = ist2(ptr, 0);
goto http_msg_rpline_eol;
case H1_MSG_RPCODE_SP:

View File

@ -402,7 +402,7 @@ int h2_make_htx_request(struct http_hdr *list, struct htx *htx, unsigned int *ms
lck = ck = -1; // no cookie for now
fields = 0;
for (idx = 0; list[idx].n.len != 0; idx++) {
if (!list[idx].n.ptr) {
if (!isttest(list[idx].n)) {
/* this is an indexed pseudo-header */
phdr = list[idx].n.len;
}
@ -721,7 +721,7 @@ int h2_make_htx_response(struct http_hdr *list, struct htx *htx, unsigned int *m
fields = 0;
for (idx = 0; list[idx].n.len != 0; idx++) {
if (!list[idx].n.ptr) {
if (!isttest(list[idx].n)) {
/* this is an indexed pseudo-header */
phdr = list[idx].n.len;
}
@ -873,7 +873,7 @@ int h2_make_htx_trailers(struct http_hdr *list, struct htx *htx)
int i;
for (idx = 0; list[idx].n.len != 0; idx++) {
if (!list[idx].n.ptr) {
if (!isttest(list[idx].n)) {
/* This is an indexed pseudo-header (RFC7540#8.1.2.1) */
goto fail;
}

View File

@ -1099,7 +1099,7 @@ static int smp_fetch_base(const struct arg *args, struct sample *smp, const char
/* OK we have the header value in ctx.value */
temp = get_trash_chunk();
chunk_memcat(temp, ctx.value.ptr, ctx.value.len);
chunk_istcat(temp, ctx.value);
/* now retrieve the path */
sl = http_get_stline(htx);

View File

@ -139,7 +139,7 @@ static int __http_find_header(const struct htx *htx, const void *pattern, struct
if (flags & HTTP_FIND_FL_FULL)
goto next_blk;
v = htx_get_blk_value(htx, blk);
p = ctx->value.ptr + ctx->value.len + ctx->lws_after;
p = istend(ctx->value) + ctx->lws_after;
v.len -= (p - v.ptr);
v.ptr = p;
if (!v.len)
@ -574,8 +574,7 @@ int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const s
}
ctx->blk = blk;
ctx->value.ptr = v.ptr + off;
ctx->value.len = data.len;
ctx->value = ist2(v.ptr + off, data.len);
ctx->lws_before = ctx->lws_after = 0;
return 1;
@ -674,8 +673,7 @@ int http_remove_header(struct htx *htx, struct http_hdr_ctx *ctx)
htx_change_blk_value_len(htx, blk, v.len-len);
/* Finally update the ctx */
ctx->value.ptr = start;
ctx->value.len = 0;
ctx->value = ist2(start, 0);
ctx->lws_before = ctx->lws_after = 0;
return 1;
@ -1057,7 +1055,7 @@ static int http_htx_init(void)
continue;
}
raw = ist2(http_err_msgs[rc], strlen(http_err_msgs[rc]));
raw = ist(http_err_msgs[rc]);
if (!http_str_to_htx(&chk, raw, &errmsg)) {
ha_alert("Internal error: invalid default message for HTTP return code %d: %s.\n",
http_err_codes[rc], errmsg);

View File

@ -1803,7 +1803,7 @@ void __send_log(struct list *logsrvs, struct buffer *tagb, int level,
if (!metadata[LOG_META_HOST].len) {
if (global.log_send_hostname)
metadata[LOG_META_HOST] = ist2(global.log_send_hostname, strlen(global.log_send_hostname));
metadata[LOG_META_HOST] = ist(global.log_send_hostname);
}
if (!tagb || !tagb->area)

View File

@ -1417,7 +1417,7 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
params->scriptname = ist2(b_tail(params->p), len+fconn->app->index.len);
chunk_istcat(params->p, sn);
chunk_memcat(params->p, fconn->app->index.ptr, fconn->app->index.len);
chunk_istcat(params->p, fconn->app->index);
}
}
@ -1494,16 +1494,16 @@ static int fcgi_encode_default_param(struct fcgi_conn *fconn, struct fcgi_strm *
goto encode;
case FCGI_SP_SCRIPT_FILE:
p.n = ist("SCRIPT_FILENAME");
chunk_memcat(&trash, params->docroot.ptr, params->docroot.len);
chunk_memcat(&trash, params->scriptname.ptr, params->scriptname.len);
chunk_istcat(&trash, params->docroot);
chunk_istcat(&trash, params->scriptname);
p.v = ist2(b_head(&trash), b_data(&trash));
goto encode;
case FCGI_SP_PATH_TRANS:
if (!istlen(params->pathinfo))
goto skip;
p.n = ist("PATH_TRANSLATED");
chunk_memcat(&trash, params->docroot.ptr, params->docroot.len);
chunk_memcat(&trash, params->pathinfo.ptr, params->pathinfo.len);
chunk_istcat(&trash, params->docroot);
chunk_istcat(&trash, params->pathinfo);
p.v = ist2(b_head(&trash), b_data(&trash));
goto encode;
case FCGI_SP_CONT_LEN:

View File

@ -2595,7 +2595,7 @@ static int h1_send_error(struct h1c *h1c)
TRACE_STATE("waiting for h1c obuf allocation", H1_EV_H1C_ERR|H1_EV_H1C_BLK, h1c->conn);
goto out;
}
ret = b_istput(&h1c->obuf, ist2(http_err_msgs[rc], strlen(http_err_msgs[rc])));
ret = b_istput(&h1c->obuf, ist(http_err_msgs[rc]));
if (unlikely(ret <= 0)) {
if (!ret) {
h1c->flags |= (H1C_F_OUT_FULL|H1C_F_ERR_PENDING);

View File

@ -205,7 +205,7 @@ int sink_announce_dropped(struct sink *sink, int facility)
if (!metadata[LOG_META_HOST].len) {
if (global.log_send_hostname)
metadata[LOG_META_HOST] = ist2(global.log_send_hostname, strlen(global.log_send_hostname));
metadata[LOG_META_HOST] = ist(global.log_send_hostname);
}
if (!metadata[LOG_META_TAG].len)

View File

@ -4992,7 +4992,7 @@ static struct tcpcheck_rule *proxy_parse_httpchk_req(char **args, int cur_arg, s
}
LIST_INIT(&hdr->value);
hdr->name = istdup(tmp_hdrs[i].n);
if (!hdr->name.ptr) {
if (!isttest(hdr->name)) {
memprintf(errmsg, "out of memory");
goto error;
}