]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: Use isttest(const struct ist) whenever possible
authorTim Duesterhus <tim@bastelstu.be>
Tue, 2 Mar 2021 17:57:28 +0000 (18:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Mar 2021 04:07:10 +0000 (05:07 +0100)
Refactoring performed with the following Coccinelle patch:

    @@
    struct ist i;
    @@

    - i.ptr != NULL
    + isttest(i)

src/backend.c
src/hpack-dec.c
src/log.c
src/mux_h1.c
src/mux_h2.c
src/trace.c

index 3cf8b27b8f53884e39e5199e46965baec93f5978..e26167984dfe79a105c1b581b7645f30e67b658e 100644 (file)
@@ -721,7 +721,7 @@ int assign_server(struct stream *s)
                                        uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
                                        if (s->be->lbprm.arg_opt1 & 2) {
                                                uri = http_get_path(uri);
-                                               if (!uri.ptr)
+                                               if (!isttest(uri))
                                                        uri = ist("");
                                        }
                                        srv = get_server_uh(s->be, uri.ptr, uri.len, prev_srv);
index debd6119dc054e41ee7d57196b29077a57eb8f9d..4fa9bfd08298de56448be19f67850a9625abeaa2 100644 (file)
@@ -118,7 +118,7 @@ static inline struct ist hpack_alloc_string(struct buffer *store, uint32_t idx,
 
        out.len = in.len;
        out.ptr = chunk_newstr(store);
-       if (unlikely(!out.ptr))
+       if (unlikely(!isttest(out)))
                return out;
 
        if (unlikely(store->data + out.len > store->size)) {
index a7ffd9c723887f7ffad3ee5df34781fd6c58b29c..2bf7f15805cd162e7e611f605ecca512abe6468a 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -3562,7 +3562,7 @@ void parse_log_message(char *buf, size_t buflen, int *level, int *facility,
                                metadata[LOG_META_TAG].len = p - metadata[LOG_META_TAG].ptr;
                                metadata[LOG_META_PID].ptr = p + 1;
                        }
-                       else if (*p == ']' && metadata[LOG_META_PID].ptr) {
+                       else if (*p == ']' && isttest(metadata[LOG_META_PID])) {
                                if (p[1] != ':')
                                        return;
                                metadata[LOG_META_PID].len = p - metadata[LOG_META_PID].ptr;
index 0ee477282da9564c350e38e6a0f2bde6fb086c30..17ce3152fb7285ca391ba9b71db6f61415d2fe22 100644 (file)
@@ -3586,7 +3586,7 @@ static int add_hdr_case_adjust(const char *from, const char *to, char **err)
 
        entry->node.key = strdup(from);
        entry->name = ist2(strdup(to), strlen(to));
-       if (!entry->node.key || !entry->name.ptr) {
+       if (!entry->node.key || !isttest(entry->name)) {
                free(entry->node.key);
                istfree(&entry->name);
                free(entry);
index 46940b40453b52d939d9057cc28ff76f65872280..b406c8a8e2f8d91eca142e88a3290d291853cad5 100644 (file)
@@ -5462,7 +5462,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
                         * is present, otherwise it must be deleted.
                         */
                        v = istist(v, ist("trailers"));
-                       if (!v.ptr || (v.len > 8 && v.ptr[8] != ','))
+                       if (!isttest(v) || (v.len > 8 && v.ptr[8] != ','))
                                continue;
                        v = ist("trailers");
                }
index f72002d415e164b9ea7aeda0bdc53d2342cca86e..85eb2cf917afb2c0953e0cda11d3331337c2ed32 100644 (file)
@@ -200,7 +200,7 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
        words++;
        line[words++] = ist("] ");
 
-       if (ist_func.ptr) {
+       if (isttest(ist_func)) {
                line[words++] = ist_func;
                line[words++] = ist("(): ");
        }