From: Willy Tarreau Date: Wed, 6 Oct 2021 13:19:05 +0000 (+0200) Subject: CLEANUP: sample: rename sample_conv_var2smp() to *_sint X-Git-Tag: v2.3.15~46 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=04a30d455d57e7e2dee4dd2efced078d1933f115;p=haproxy-2.3.git CLEANUP: sample: rename sample_conv_var2smp() to *_sint This one only handles integers, contrary to its sibling with the suffix _str that only handles strings. Let's rename it and uninline it since it may well be used from outside. (cherry picked from commit d9be59952975e679f3305e32620ae3572a6a952c) Signed-off-by: Christopher Faulet (cherry picked from commit 9cfb71fb345c1c95377c0f2e72aff2a80aa10fc2) Signed-off-by: Christopher Faulet --- diff --git a/include/haproxy/sample.h b/include/haproxy/sample.h index e5378b0..5389b2a 100644 --- a/include/haproxy/sample.h +++ b/include/haproxy/sample.h @@ -40,6 +40,7 @@ struct sample *sample_process(struct proxy *px, struct session *sess, struct sample *sample_fetch_as_type(struct proxy *px, struct session *sess, struct stream *strm, unsigned int opt, struct sample_expr *expr, int smp_type); +int sample_conv_var2smp_sint(const struct arg *arg, struct sample *smp); void release_sample_expr(struct sample_expr *expr); void sample_register_fetches(struct sample_fetch_kw_list *psl); void sample_register_convs(struct sample_conv_kw_list *psl); diff --git a/src/sample.c b/src/sample.c index cc4f7df..8cc41d7 100644 --- a/src/sample.c +++ b/src/sample.c @@ -2790,7 +2790,7 @@ static int check_operator(struct arg *args, struct sample_conv *conv, * * This function returns 0 if an error occurs, otherwise it returns 1. */ -static inline int sample_conv_var2smp(const struct arg *arg, struct sample *smp) +int sample_conv_var2smp_sint(const struct arg *arg, struct sample *smp) { switch (arg->type) { case ARGT_SINT: @@ -2827,7 +2827,7 @@ static int sample_conv_binary_and(const struct arg *arg_p, struct sample *smp, v struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; smp->data.u.sint &= tmp.data.u.sint; return 1; @@ -2841,7 +2841,7 @@ static int sample_conv_binary_or(const struct arg *arg_p, struct sample *smp, vo struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; smp->data.u.sint |= tmp.data.u.sint; return 1; @@ -2855,7 +2855,7 @@ static int sample_conv_binary_xor(const struct arg *arg_p, struct sample *smp, v struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; smp->data.u.sint ^= tmp.data.u.sint; return 1; @@ -2895,7 +2895,7 @@ static int sample_conv_arith_add(const struct arg *arg_p, struct sample *smp, vo struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; smp->data.u.sint = arith_add(smp->data.u.sint, tmp.data.u.sint); return 1; @@ -2910,7 +2910,7 @@ static int sample_conv_arith_sub(const struct arg *arg_p, struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; /* We cannot represent -LLONG_MIN because abs(LLONG_MIN) is greater @@ -2943,7 +2943,7 @@ static int sample_conv_arith_mul(const struct arg *arg_p, long long int c; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; /* prevent divide by 0 during the check */ @@ -2987,7 +2987,7 @@ static int sample_conv_arith_div(const struct arg *arg_p, struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; if (tmp.data.u.sint) { @@ -3015,7 +3015,7 @@ static int sample_conv_arith_mod(const struct arg *arg_p, struct sample tmp; smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt); - if (!sample_conv_var2smp(arg_p, &tmp)) + if (!sample_conv_var2smp_sint(arg_p, &tmp)) return 0; if (tmp.data.u.sint) {