From e296d3e5f00c33152d4153ee6d5dc5b728ee8343 Mon Sep 17 00:00:00 2001 From: Tim Duesterhus Date: Thu, 5 Mar 2020 17:56:31 +0100 Subject: [PATCH] MINOR: ist: Add `int isttest(const struct ist)` `isttest` returns whether the `.ptr` is non-null. --- include/common/ist.h | 6 ++++++ src/http_ana.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/common/ist.h b/include/common/ist.h index a1d8218..aa25a1f 100644 --- a/include/common/ist.h +++ b/include/common/ist.h @@ -186,6 +186,12 @@ static inline struct ist ist2(const void *ptr, size_t len) return (struct ist){ .ptr = (char *)ptr, .len = len }; } +/* returns the result of `ist.ptr != NULL` */ +static inline int isttest(const struct ist ist) +{ + return ist.ptr != NULL; +} + /* This function MODIFIES the string to add a zero AFTER the end, and returns * the start pointer. The purpose is to use it on strings extracted by parsers * from larger strings cut with delimiters that are not important and can be diff --git a/src/http_ana.c b/src/http_ana.c index 094208d..e268d4c 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -2787,7 +2787,7 @@ int http_res_set_status(unsigned int status, struct ist reason, struct stream *s trash.data = res - trash.area; /* Do we have a custom reason format string? */ - if (reason.ptr == NULL) { + if (!isttest(reason)) { const char *str = http_get_reason(status); reason = ist2(str, strlen(str)); } -- 1.7.10.4