]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: payload: remove useless and confusing nullity checks for channel buffer
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Mar 2016 15:53:03 +0000 (16:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Mar 2016 16:28:04 +0000 (17:28 +0100)
The buffer could not be null by definition since we moved the stream out
of the session. It's the stream which gained the ability to be NULL (hence
the recent fix for this case). The checks in place are useless and make one
think this situation can happen.

src/payload.c

index 620ebe4346e2cc9a05de0083015e9f5b2cc1f0b7..0cac555da01d2c0cf1bffcd76a5ba2eb338d8670 100644 (file)
@@ -50,9 +50,6 @@ smp_fetch_len(const struct arg *args, struct sample *smp, const char *kw, void *
                return 0;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               return 0;
-
        smp->data.type = SMP_T_SINT;
        smp->data.u.sint = chn->buf->i;
        smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
@@ -75,9 +72,6 @@ smp_fetch_req_ssl_st_ext(const struct arg *args, struct sample *smp, const char
                goto not_ssl_hello;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               goto not_ssl_hello;
-
        bleft = chn->buf->i;
        data = (unsigned char *)chn->buf->p;
 
@@ -211,9 +205,6 @@ smp_fetch_req_ssl_ec_ext(const struct arg *args, struct sample *smp, const char
                goto not_ssl_hello;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               goto not_ssl_hello;
-
        bleft = chn->buf->i;
        data = (unsigned char *)chn->buf->p;
 
@@ -335,9 +326,6 @@ smp_fetch_ssl_hello_type(const struct arg *args, struct sample *smp, const char
                goto not_ssl_hello;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               goto not_ssl_hello;
-
        bleft = chn->buf->i;
        data = (const unsigned char *)chn->buf->p;
 
@@ -404,9 +392,6 @@ smp_fetch_req_ssl_ver(const struct arg *args, struct sample *smp, const char *kw
                return 0;
 
        req = &smp->strm->req;
-       if (!req->buf)
-               return 0;
-
        msg_len = 0;
        bleft = req->buf->i;
        if (!bleft)
@@ -547,9 +532,6 @@ smp_fetch_ssl_hello_sni(const struct arg *args, struct sample *smp, const char *
                goto not_ssl_hello;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               goto not_ssl_hello;
-
        bleft = chn->buf->i;
        data = (unsigned char *)chn->buf->p;
 
@@ -681,9 +663,6 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
        int bleft;
        const unsigned char *data;
 
-       if (!s->req.buf)
-               return 0;
-
        smp->flags = SMP_F_CONST;
        smp->data.type = SMP_T_STR;
 
@@ -812,9 +791,6 @@ smp_fetch_payload_lv(const struct arg *arg_p, struct sample *smp, const char *kw
                return 0;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               return 0;
-
        if (len_offset + len_size > chn->buf->i)
                goto too_short;
 
@@ -865,9 +841,6 @@ smp_fetch_payload(const struct arg *arg_p, struct sample *smp, const char *kw, v
                return 0;
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
-       if (!chn->buf)
-               return 0;
-
        if (!buf_size || buf_size > global.tune.bufsize || buf_offset + buf_size > global.tune.bufsize) {
                /* will never match */
                smp->flags = 0;