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/ --- src/cache.c | 2 +- src/fcgi.c | 12 ++++-------- src/flt_http_comp.c | 12 ++++++------ src/h1.c | 6 ++---- src/h2.c | 6 +++--- src/http_fetch.c | 2 +- src/http_htx.c | 10 ++++------ src/log.c | 2 +- src/mux_fcgi.c | 10 +++++----- src/mux_h1.c | 2 +- src/sink.c | 2 +- src/tcpcheck.c | 2 +- 12 files changed, 30 insertions(+), 38 deletions(-) diff --git a/src/cache.c b/src/cache.c index 60f9a0ed7..0f90af984 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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; diff --git a/src/fcgi.c b/src/fcgi.c index 1c2543def..dcf2db219 100644 --- a/src/fcgi.c +++ b/src/fcgi.c @@ -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; diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index f2b210a67..08f684e51 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -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++; } diff --git a/src/h1.c b/src/h1.c index dd208f323..bf546b9d7 100644 --- a/src/h1.c +++ b/src/h1.c @@ -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: diff --git a/src/h2.c b/src/h2.c index 49a1252e9..5c3a6aeaf 100644 --- a/src/h2.c +++ b/src/h2.c @@ -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; } diff --git a/src/http_fetch.c b/src/http_fetch.c index 22919d354..2ee507b65 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -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); diff --git a/src/http_htx.c b/src/http_htx.c index 3535fa713..d9584abae 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -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); diff --git a/src/log.c b/src/log.c index 3e20c1cc0..16d650d54 100644 --- a/src/log.c +++ b/src/log.c @@ -1791,7 +1791,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) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index ef264edae..8a7fc5acb 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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: diff --git a/src/mux_h1.c b/src/mux_h1.c index 3ddf6ef86..7b336faba 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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); diff --git a/src/sink.c b/src/sink.c index aa0ecfa26..00270305f 100644 --- a/src/sink.c +++ b/src/sink.c @@ -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) diff --git a/src/tcpcheck.c b/src/tcpcheck.c index ba9321eb1..1926311f7 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -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; } -- 2.35.1