mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: sample: remove useless tests in fetch functions for l4 != NULL
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.
This commit is contained in:
parent
9ad7bd48d2
commit
53c9b4db41
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user