]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: http-rules: fix a few '&' vs '&&' checks for clarity
authorWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 12:54:01 +0000 (14:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 14:04:19 +0000 (16:04 +0200)
In http_re{q,s}_get_intercept_rule(), there are two occurrences of '&'
being used instead of '&&' which fortunately work thanks to the tests
being negations (hence 0/1 on each branch). Let's fix that and take this
opportunity for adding explicit precedence in http_apply_redirect_rule().

src/http_ana.c

index fbe529866736a9433cc0d6278d0edf218fb7d604..c687b57d91c5066eccd2156185fdaff621afec4b 100644 (file)
@@ -2528,7 +2528,7 @@ int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struc
                                size_t len = build_logline(s, chunk->area + chunk->data,
                                                           chunk->size - chunk->data,
                                                           &rule->rdr_fmt);
-                               if (!len && rule->flags & REDIRECT_FLAG_IGNORE_EMPTY) {
+                               if (!len && (rule->flags & REDIRECT_FLAG_IGNORE_EMPTY)) {
                                        ret = 2;
                                        goto out;
                                }
@@ -2879,7 +2879,7 @@ static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct lis
 
                /* Always call the action function if defined */
                if (rule->action_ptr) {
-                       if (!(s->scf->flags & SC_FL_ERROR) & !(s->req.flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
+                       if (!(s->scf->flags & SC_FL_ERROR) && !(s->req.flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
                                s->waiting_entity.type = STRM_ENTITY_NONE;
                                s->waiting_entity.ptr  = NULL;
                        }
@@ -3071,7 +3071,7 @@ resume_execution:
 
                /* Always call the action function if defined */
                if (rule->action_ptr) {
-                       if (!(s->scb->flags & SC_FL_ERROR) & !(s->res.flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
+                       if (!(s->scb->flags & SC_FL_ERROR) && !(s->res.flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
                                s->waiting_entity.type = STRM_ENTITY_NONE;
                                s->waiting_entity.ptr  = NULL;
                        }