CLEANUP: Use ist2(const void*, size_t) whenever possible
Refactoring performed with the following Coccinelle patch:
@@
struct ist i;
expression p, l;
@@
- i.ptr = p;
- i.len = l;
+ i = ist2(p, l);
diff --git a/src/51d.c b/src/51d.c
index f36f5fa..6cd1d28 100644
--- a/src/51d.c
+++ b/src/51d.c
@@ -242,8 +242,8 @@
ALREADY_CHECKED(htx);
for (i = 0; i < global_51degrees.header_count; i++) {
- name.ptr = (global_51degrees.header_names + i)->area;
- name.len = (global_51degrees.header_names + i)->data;
+ name = ist2((global_51degrees.header_names + i)->area,
+ (global_51degrees.header_names + i)->data);
ctx.blk = NULL;
if (http_find_header(htx, name, &ctx, 1)) {
@@ -281,8 +281,8 @@
ALREADY_CHECKED(htx);
for (i = 0; i < global_51degrees.header_count; i++) {
- name.ptr = (global_51degrees.header_names + i)->area;
- name.len = (global_51degrees.header_names + i)->data;
+ name = ist2((global_51degrees.header_names + i)->area,
+ (global_51degrees.header_names + i)->data);
ctx.blk = NULL;
if (http_find_header(htx, name, &ctx, 1)) {
diff --git a/src/dns.c b/src/dns.c
index 835975c..dcdc163 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -105,8 +105,7 @@
if (errno == EAGAIN) {
struct ist myist;
- myist.ptr = buf;
- myist.len = len;
+ myist = ist2(buf, len);
ret = ring_write(ns->dgram->ring_req, DNS_TCP_MSG_MAX_SIZE, NULL, 0, &myist, 1);
if (!ret) {
ns->counters->snd_error++;
@@ -125,8 +124,7 @@
else if (ns->stream) {
struct ist myist;
- myist.ptr = buf;
- myist.len = len;
+ myist = ist2(buf, len);
ret = ring_write(ns->stream->ring_req, DNS_TCP_MSG_MAX_SIZE, NULL, 0, &myist, 1);
if (!ret) {
ns->counters->snd_error++;
@@ -1123,8 +1121,7 @@
len = b_getblk(buf, dns_msg_trash, msg_len, ofs + cnt);
- myist.ptr = dns_msg_trash;
- myist.len = len;
+ myist = ist2(dns_msg_trash, len);
ads = NULL;
/* try to push request into active sess with free slot */
diff --git a/src/http_fetch.c b/src/http_fetch.c
index 6ccd9dd..c73546b 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -770,8 +770,7 @@
if (args[0].type != ARGT_STR)
return 0;
- name.ptr = args[0].data.str.area;
- name.len = args[0].data.str.data;
+ name = ist2(args[0].data.str.area, args[0].data.str.data);
if (args[1].type == ARGT_SINT)
occ = args[1].data.sint;
@@ -817,11 +816,9 @@
return 0;
if (args->type == ARGT_STR) {
- name.ptr = args->data.str.area;
- name.len = args->data.str.data;
+ name = ist2(args->data.str.area, args->data.str.data);
} else {
- name.ptr = NULL;
- name.len = 0;
+ name = ist2(NULL, 0);
}
ctx.blk = NULL;
@@ -899,8 +896,7 @@
if (args[0].type != ARGT_STR)
return 0;
- name.ptr = args[0].data.str.area;
- name.len = args[0].data.str.data;
+ name = ist2(args[0].data.str.area, args[0].data.str.data);
if (args[1].type == ARGT_SINT)
occ = args[1].data.sint;
@@ -956,11 +952,9 @@
return 0;
if (args->type == ARGT_STR) {
- name.ptr = args->data.str.area;
- name.len = args->data.str.data;
+ name = ist2(args->data.str.area, args->data.str.data);
} else {
- name.ptr = NULL;
- name.len = 0;
+ name = ist2(NULL, 0);
}
ctx.blk = NULL;
diff --git a/src/log.c b/src/log.c
index bc586e1..a7ffd9c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -2915,8 +2915,7 @@
while (spc < end && !HTTP_IS_SPHT(*spc))
spc++;
- path.ptr = uri;
- path.len = spc - uri;
+ path = ist2(uri, spc - uri);
// extract relative path without query params from url
path = iststop(http_get_path(path), '?');
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 5ff3d54..0ee4772 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -3585,8 +3585,7 @@
}
entry->node.key = strdup(from);
- entry->name.ptr = strdup(to);
- entry->name.len = strlen(to);
+ entry->name = ist2(strdup(to), strlen(to));
if (!entry->node.key || !entry->name.ptr) {
free(entry->node.key);
istfree(&entry->name);
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 1d1c6bb..4bffd45 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -5366,8 +5366,7 @@
uri.len -= len + 3;
/* find the auth part of the URI */
- auth.ptr = uri.ptr;
- auth.len = 0;
+ auth = ist2(uri.ptr, 0);
while (auth.len < uri.len && auth.ptr[auth.len] != '/')
auth.len++;
diff --git a/src/trace.c b/src/trace.c
index d3722a1..f72002d 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -216,8 +216,7 @@
b_reset(&trace_buf);
b_istput(&trace_buf, msg);
cb(level, mask, src, where, ist_func, a1, a2, a3, a4);
- line[words].ptr = trace_buf.area;
- line[words].len = trace_buf.data;
+ line[words] = ist2(trace_buf.area, trace_buf.data);
words++;
}
else {
diff --git a/src/wurfl.c b/src/wurfl.c
index 02e1dd4..6030c4c 100644
--- a/src/wurfl.c
+++ b/src/wurfl.c
@@ -742,8 +742,7 @@
return NULL;
}
- name.ptr = (char *)header_name;
- name.len = strlen(header_name);
+ name = ist2((char *)header_name, strlen(header_name));
// If 4th param is set, it works on full-line headers in whose comma is not a delimiter but is
// part of the syntax