]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: sample: remove useless tests in fetch functions for l4 != NULL
authorWilly Tarreau <w@1wt.eu>
Fri, 3 Apr 2015 19:38:18 +0000 (21:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Apr 2015 09:35:52 +0000 (11:35 +0200)
The stream may never be null given that all these functions are called
from sample_process(). Let's remove this now confusing test which
sometimes happens after a dereference was already done.

src/payload.c
src/proto_http.c
src/ssl_sock.c

index 3a2dc1553c5e26b8b3a7b354f5191b0cd87646b1..9d7774c28526cd8dd4922c08132366d1d2017e13 100644 (file)
@@ -48,9 +48,6 @@ smp_fetch_len(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
 {
        struct channel *chn;
 
-       if (!s)
-               return 0;
-
        chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &s->res : &s->req;
        if (!chn->buf)
                return 0;
@@ -71,9 +68,6 @@ smp_fetch_ssl_hello_type(struct proxy *px, struct stream *s, void *l7, unsigned
        struct channel *chn;
        const unsigned char *data;
 
-       if (!s)
-               goto not_ssl_hello;
-
        chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &s->res : &s->req;
        if (!chn->buf)
                goto not_ssl_hello;
@@ -140,7 +134,7 @@ smp_fetch_req_ssl_ver(struct proxy *px, struct stream *s, void *l7, unsigned int
        int version, bleft, msg_len;
        const unsigned char *data;
 
-       if (!s || !s->req.buf)
+       if (!s->req.buf)
                return 0;
 
        msg_len = 0;
@@ -277,9 +271,6 @@ smp_fetch_ssl_hello_sni(struct proxy *px, struct stream *s, void *l7, unsigned i
        struct channel *chn;
        unsigned char *data;
 
-       if (!s)
-               goto not_ssl_hello;
-
        chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &s->res : &s->req;
        if (!chn->buf)
                goto not_ssl_hello;
@@ -415,7 +406,7 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
        int bleft;
        const unsigned char *data;
 
-       if (!s || !s->req.buf)
+       if (!s->req.buf)
                return 0;
 
        smp->flags = SMP_F_CONST;
@@ -542,9 +533,6 @@ smp_fetch_payload_lv(struct proxy *px, struct stream *s, void *l7, unsigned int
        /* by default buf offset == len offset + len size */
        /* buf offset could be absolute or relative to len offset + len size if prefixed by + or - */
 
-       if (!s)
-               return 0;
-
        chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &s->res : &s->req;
        if (!chn->buf)
                return 0;
@@ -592,9 +580,6 @@ smp_fetch_payload(struct proxy *px, struct stream *s, void *l7, unsigned int opt
        unsigned int buf_size = arg_p[1].data.uint;
        struct channel *chn;
 
-       if (!s)
-               return 0;
-
        chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &s->res : &s->req;
        if (!chn->buf)
                return 0;
index 3e874701ce5dd1762704328d07c78a18c3795d0e..f5149282ec76a6e53caa91963c22f2556673fd1c 100644 (file)
@@ -10671,9 +10671,6 @@ static int
 smp_fetch_http_first_req(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
                          const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-       if (!s)
-               return 0;
-
        smp->type = SMP_T_BOOL;
        smp->data.uint = !(s->txn.flags & TX_NOT_FIRST);
        return 1;
index 39d759ed129a934344187a2570b2f348b8d04224..e06e96d97522fc2cb2bf48aa0b312fa0a5b13593 100644 (file)
@@ -3090,9 +3090,6 @@ smp_fetch_ssl_fc_has_crt(struct proxy *px, struct stream *l4, void *l7, unsigned
        struct connection *conn;
        struct session *sess = l4->sess;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3124,9 +3121,6 @@ smp_fetch_ssl_x_der(struct proxy *px, struct stream *l4, void *l7, unsigned int
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3173,9 +3167,6 @@ smp_fetch_ssl_x_serial(struct proxy *px, struct stream *l4, void *l7, unsigned i
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3223,9 +3214,6 @@ smp_fetch_ssl_x_sha1(struct proxy *px, struct stream *l4, void *l7, unsigned int
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3271,9 +3259,6 @@ smp_fetch_ssl_x_notafter(struct proxy *px, struct stream *l4, void *l7, unsigned
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3320,9 +3305,6 @@ smp_fetch_ssl_x_i_dn(struct proxy *px, struct stream *l4, void *l7, unsigned int
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3383,9 +3365,6 @@ smp_fetch_ssl_x_notbefore(struct proxy *px, struct stream *l4, void *l7, unsigne
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3432,9 +3411,6 @@ smp_fetch_ssl_x_s_dn(struct proxy *px, struct stream *l4, void *l7, unsigned int
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3489,9 +3465,6 @@ smp_fetch_ssl_c_used(struct proxy *px, struct stream *l4, void *l7, unsigned int
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3525,9 +3498,6 @@ smp_fetch_ssl_x_version(struct proxy *px, struct stream *l4, void *l7, unsigned
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3567,9 +3537,6 @@ smp_fetch_ssl_x_sig_alg(struct proxy *px, struct stream *l4, void *l7, unsigned
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3620,9 +3587,6 @@ smp_fetch_ssl_x_key_alg(struct proxy *px, struct stream *l4, void *l7, unsigned
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -3706,9 +3670,6 @@ smp_fetch_ssl_fc_cipher(struct proxy *px, struct stream *l4, void *l7, unsigned
 
        smp->flags = 0;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(l4->si[back_conn].end);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3738,9 +3699,6 @@ smp_fetch_ssl_fc_alg_keysize(struct proxy *px, struct stream *l4, void *l7, unsi
 
        smp->flags = 0;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(l4->si[back_conn].end);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3766,9 +3724,6 @@ smp_fetch_ssl_fc_use_keysize(struct proxy *px, struct stream *l4, void *l7, unsi
 
        smp->flags = 0;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(l4->si[back_conn].end);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3793,9 +3748,6 @@ smp_fetch_ssl_fc_npn(struct proxy *px, struct stream *l4, void *l7, unsigned int
        smp->flags = SMP_F_CONST;
        smp->type = SMP_T_STR;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3822,9 +3774,6 @@ smp_fetch_ssl_fc_alpn(struct proxy *px, struct stream *l4, void *l7, unsigned in
        smp->flags = SMP_F_CONST;
        smp->type = SMP_T_STR;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3853,9 +3802,6 @@ smp_fetch_ssl_fc_protocol(struct proxy *px, struct stream *l4, void *l7, unsigne
 
        smp->flags = 0;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(l4->si[back_conn].end);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3887,9 +3833,6 @@ smp_fetch_ssl_fc_session_id(struct proxy *px, struct stream *l4, void *l7, unsig
        smp->flags = SMP_F_CONST;
        smp->type = SMP_T_BIN;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(l4->si[back_conn].end);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3919,9 +3862,6 @@ smp_fetch_ssl_fc_sni(struct proxy *px, struct stream *l4, void *l7, unsigned int
        smp->flags = SMP_F_CONST;
        smp->type = SMP_T_STR;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3949,9 +3889,6 @@ smp_fetch_ssl_fc_unique_id(struct proxy *px, struct stream *l4, void *l7, unsign
 
        smp->flags = 0;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(l4->si[back_conn].end);
        if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
                return 0;
@@ -3988,9 +3925,6 @@ smp_fetch_ssl_c_ca_err(struct proxy *px, struct stream *l4, void *l7, unsigned i
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -4015,9 +3949,6 @@ smp_fetch_ssl_c_ca_err_depth(struct proxy *px, struct stream *l4, void *l7, unsi
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -4042,9 +3973,6 @@ smp_fetch_ssl_c_err(struct proxy *px, struct stream *l4, void *l7, unsigned int
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;
@@ -4069,9 +3997,6 @@ smp_fetch_ssl_c_verify(struct proxy *px, struct stream *l4, void *l7, unsigned i
        struct session *sess = strm_sess(l4);
        struct connection *conn;
 
-       if (!l4)
-               return 0;
-
        conn = objt_conn(sess->origin);
        if (!conn || conn->xprt != &ssl_sock)
                return 0;