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/
diff --git a/src/cache.c b/src/cache.c
index 60f9a0e..0f90af9 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -626,7 +626,7 @@
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 1c2543d..dcf2db2 100644
--- a/src/fcgi.c
+++ b/src/fcgi.c
@@ -197,10 +197,8 @@
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 @@
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 f2b210a..08f684e 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -400,26 +400,26 @@
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 dd208f3..bf546b9 100644
--- a/src/h1.c
+++ b/src/h1.c
@@ -428,8 +428,7 @@
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 @@
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 49a1252..5c3a6ae 100644
--- a/src/h2.c
+++ b/src/h2.c
@@ -402,7 +402,7 @@
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 @@
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 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 22919d3..2ee507b 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -1099,7 +1099,7 @@
/* 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 3535fa7..d9584ab 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -139,7 +139,7 @@
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 @@
}
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 @@
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 @@
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 9952aaa..744cb03 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1803,7 +1803,7 @@
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 ef264ed..8a7fc5a 100644
--- a/src/mux_fcgi.c
+++ b/src/mux_fcgi.c
@@ -1417,7 +1417,7 @@
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 @@
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 3e2ea26..886caaa 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -2595,7 +2595,7 @@
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 dd6f6b0..eec8570 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -205,7 +205,7 @@
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 ba9321e..1926311 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -4992,7 +4992,7 @@
}
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;
}