This cleans up ist handling.
---
 addons/ot/src/http.c               |  9 +++------
 addons/promex/service-prometheus.c |  2 +-
 include/haproxy/htx.h              | 12 ++++++------
 src/hlua.c                         |  5 ++---
 src/stream.c                       |  2 +-
 5 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/addons/ot/src/http.c b/addons/ot/src/http.c
index 0d824ddb5..3376a3b00 100644
--- a/addons/ot/src/http.c
+++ b/addons/ot/src/http.c
@@ -220,12 +220,10 @@ int flt_ot_http_header_set(struct channel *chn, const 
char *prefix, const char *
        }
 
        if (!FLT_OT_STR_ISVALID(prefix)) {
-               ist_name.ptr = (char *)name;
-               ist_name.len = strlen(name);
+               ist_name = ist2((char *)name, strlen(name));
        }
        else if (!FLT_OT_STR_ISVALID(name)) {
-               ist_name.ptr = (char *)prefix;
-               ist_name.len = strlen(prefix);
+               ist_name = ist2((char *)prefix, strlen(prefix));
        }
        else {
                buffer = flt_ot_trash_alloc(0, err);
@@ -234,8 +232,7 @@ int flt_ot_http_header_set(struct channel *chn, const char 
*prefix, const char *
 
                (void)chunk_printf(buffer, "%s-%s", prefix, name);
 
-               ist_name.ptr = buffer->area;
-               ist_name.len = buffer->data;
+               ist_name = ist2(buffer->area, buffer->data);
        }
 
        /* Remove all occurrences of the header. */
diff --git a/addons/promex/service-prometheus.c 
b/addons/promex/service-prometheus.c
index 6a42a47c3..2070b9c1f 100644
--- a/addons/promex/service-prometheus.c
+++ b/addons/promex/service-prometheus.c
@@ -1006,7 +1006,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, 
struct htx *htx)
                                                        val = 
mkf_u32(FO_STATUS, sv->check.status == appctx->ctx.stats.st_code);
                                                        check_state = 
get_check_status_info(appctx->ctx.stats.st_code);
                                                        labels[2].name = 
ist("state");
-                                                       labels[2].value = 
ist2(check_state, strlen(check_state));
+                                                       labels[2].value = 
ist(check_state);
                                                        if 
(!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[appctx->st2],
                                                                                
&val, labels, &out, max))
                                                                goto full;
diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h
index 93b3206a8..0faf29646 100644
--- a/include/haproxy/htx.h
+++ b/include/haproxy/htx.h
@@ -385,8 +385,8 @@ static inline struct ist htx_get_blk_name(const struct htx 
*htx, const struct ht
        switch (type) {
                case HTX_BLK_HDR:
                case HTX_BLK_TLR:
-                       ret.ptr = htx_get_blk_ptr(htx, blk);
-                       ret.len = blk->info & 0xff;
+                       ret = ist2(htx_get_blk_ptr(htx, blk),
+                                  blk->info & 0xff);
                        break;
 
                default:
@@ -407,15 +407,15 @@ static inline struct ist htx_get_blk_value(const struct 
htx *htx, const struct h
        switch (type) {
                case HTX_BLK_HDR:
                case HTX_BLK_TLR:
-                       ret.ptr = htx_get_blk_ptr(htx, blk) + (blk->info & 
0xff);
-                       ret.len = (blk->info >> 8) & 0xfffff;
+                       ret = ist2(htx_get_blk_ptr(htx, blk) + (blk->info & 
0xff),
+                                  (blk->info >> 8) & 0xfffff);
                        break;
 
                case HTX_BLK_REQ_SL:
                case HTX_BLK_RES_SL:
                case HTX_BLK_DATA:
-                       ret.ptr = htx_get_blk_ptr(htx, blk);
-                       ret.len = blk->info & 0xfffffff;
+                       ret = ist2(htx_get_blk_ptr(htx, blk),
+                                  blk->info & 0xfffffff);
                        break;
 
                default:
diff --git a/src/hlua.c b/src/hlua.c
index 915356c09..17f0d4842 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -6315,8 +6315,7 @@ static int _hlua_http_msg_dup(struct http_msg *msg, 
lua_State *L, size_t offset,
 
                        case HTX_BLK_DATA:
                                v = htx_get_blk_value(htx, blk);
-                               v.ptr += offset;
-                               v.len -= offset;
+                               v = istadv(v, offset);
                                if (v.len > len)
                                        v.len = len;
 
@@ -6417,7 +6416,7 @@ static void _hlua_http_msg_delete(struct http_msg *msg, 
struct filter *filter, s
                v.ptr += htxret.ret;
                if (v.len > len)
                        v.len  = len;
-               blk = htx_replace_blk_value(htx, blk, v, ist2(NULL, 0));
+               blk = htx_replace_blk_value(htx, blk, v, IST_NULL);
                len -= v.len;
                ret += v.len;
        }
diff --git a/src/stream.c b/src/stream.c
index 27062ea4b..89e85d88d 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -3010,7 +3010,7 @@ static enum act_parse_ret stream_parse_switch_mode(const 
char **args, int *cur_a
                        return ACT_RET_PRS_ERR;
                }
 
-               proto = ist2(args[*cur_arg+2], strlen(args[*cur_arg+2]));
+               proto = ist(args[*cur_arg + 2]);
                mux_proto = get_mux_proto(proto);
                if (!mux_proto) {
                        memprintf(err, "'%s %s': '%s' expects a valid MUX 
protocol, if specified (got '%s')",
-- 
2.33.0


Reply via email to