Refactoring performed with the following Coccinelle patch:

    @@
    struct ist i;
    @@

    - i.ptr != NULL
    + isttest(i)
---
 src/backend.c   | 2 +-
 src/hpack-dec.c | 2 +-
 src/log.c       | 2 +-
 src/mux_h1.c    | 2 +-
 src/mux_h2.c    | 2 +-
 src/trace.c     | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/backend.c b/src/backend.c
index 3cf8b27b8..e26167984 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -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);
diff --git a/src/hpack-dec.c b/src/hpack-dec.c
index debd6119d..4fa9bfd08 100644
--- a/src/hpack-dec.c
+++ b/src/hpack-dec.c
@@ -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)) {
diff --git a/src/log.c b/src/log.c
index a7ffd9c72..2bf7f1580 100644
--- 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;
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 0ee477282..17ce3152f 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -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);
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 46940b404..b406c8a8e 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -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");
                }
diff --git a/src/trace.c b/src/trace.c
index f72002d41..85eb2cf91 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -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("(): ");
        }
-- 
2.30.1


Reply via email to