]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: Apply ist.cocci
authorTim Duesterhus <tim@bastelstu.be>
Wed, 15 Sep 2021 11:58:44 +0000 (13:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 Sep 2021 15:22:05 +0000 (17:22 +0200)
This cleans up ist handling.

addons/ot/src/http.c
addons/promex/service-prometheus.c
include/haproxy/htx.h
src/hlua.c
src/stream.c

index 0d824ddb552321d082a0d972a8da65393a0d2a94..3376a3b009cdb7a2b2216590aabedf60729b774d 100644 (file)
@@ -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. */
index 6a42a47c308175f9b9377fbeb22cd1fa11ac8694..2070b9c1fdab01fff451e5c2e42f51c55d1e6ef6 100644 (file)
@@ -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;
index 93b3206a832d7890ef6fb0f93da4399f01a34e4c..0faf29646765b92475ed5c6ae05c947268c989a8 100644 (file)
@@ -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:
index a158c46b4f4b1ea2868143fa0856816fb6838143..4bce23f760d45072ba88089c2f1313d8481b4892 100644 (file)
@@ -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;
        }
index 27062ea4b8610a8ebfc5e1b86c0efe38d006a63c..89e85d88dee3f50a1d09cf036d8c8f03b34dc170 100644 (file)
@@ -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')",