]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ist: Add `IST_NULL` macro
authorTim Duesterhus <tim@bastelstu.be>
Thu, 5 Mar 2020 16:56:30 +0000 (17:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Mar 2020 18:52:07 +0000 (19:52 +0100)
`IST_NULL` is equivalent to an `struct ist` with `.ptr = NULL` and
`.len = 0`.

include/common/ist.h
src/hpack-dec.c
src/http.c
src/http_htx.c

index 0d8b45721812c174eeed075e3cfad29a535215c6..a1d82182bd8226fce33b4f710347789a3dd81647 100644 (file)
@@ -133,6 +133,9 @@ struct ist {
 /* makes a constant ist from a constant string, for use in array declarations */
 #define IST(str) { .ptr = str "", .len = (sizeof str "") - 1 }
 
+/* IST_NULL is equivalent to an `ist` with `.ptr = NULL` and `.len = 0` */
+#define IST_NULL ((const struct ist){ .ptr = 0, .len = 0 })
+
 /* makes an ist from a regular zero terminated string. Null has length 0.
  * Constants are detected and replaced with constant initializers. Other values
  * are measured by hand without strlen() as it's much cheaper and inlinable on
@@ -705,7 +708,7 @@ static inline struct ist istist(const struct ist ist, const struct ist pat)
                }
                return ist2(ret.ptr - 1, ret.len + 1);
        }
-       return ist2(NULL, 0);
+       return IST_NULL;
 }
 
 /*
index a721fadc468e075c76a69a466e37788119e40051..b4d8f0d393ee2ec4e22343972381b8a06a1c909e 100644 (file)
@@ -406,7 +406,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
                                value = ist2(vtrash, vlen);
                        }
 
-                       name = ist2(NULL, 0);
+                       name = IST_NULL;
                        if (!must_index)
                                name.len = hpack_idx_to_phdr(idx);
 
@@ -458,7 +458,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
        }
 
        /* put an end marker */
-       list[ret].n = list[ret].v = ist2(NULL, 0);
+       list[ret].n = list[ret].v = IST_NULL;
        ret++;
 
  leave:
index 75251992a7b94b77707f186038bb4f812d5a939f..ec6b4a2826e0cadcf0cf251c6a5cfa8c4da4be8f 100644 (file)
@@ -551,7 +551,7 @@ struct ist http_get_authority(const struct ist uri, int no_userinfo)
        return ist2(start, end - start);
 
   not_found:
-       return ist2(NULL, 0);
+       return IST_NULL;
 }
 
 /* Parse the URI from the given transaction (which is assumed to be in request
@@ -601,7 +601,7 @@ struct ist http_get_path(const struct ist uri)
        return ist2(ptr, end - ptr);
 
  not_found:
-       return ist2(NULL, 0);
+       return IST_NULL;
 }
 
 /*
index 35bb056252e2b8bd7a246529f2a44ecda78e25e7..8157eb560b0e9008d787e0bd0f78c8e96e782d45 100644 (file)
@@ -533,7 +533,7 @@ int http_remove_header(struct htx *htx, struct http_hdr_ctx *ctx)
                blk = htx_remove_blk(htx, blk);
                if (blk || htx_is_empty(htx)) {
                        ctx->blk = blk;
-                       ctx->value = ist2(NULL, 0);
+                       ctx->value = IST_NULL;
                        ctx->lws_before = ctx->lws_after = 0;
                }
                else {