]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: sample: rename sample_conv_var2smp() to *_sint
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 13:19:05 +0000 (15:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 23:36:51 +0000 (01:36 +0200)
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.

include/haproxy/sample.h
src/sample.c

index aac6efa603beb13fe1a127c9c573d9cb81da9819..e1d0a868d7586315f5d1eef8d11ccaf88e75fa3a 100644 (file)
@@ -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);
index ed95545c8e840582be5f272966d0dbd0f279b2b6..64a4b573c5f151cc91b8f192081b6560d640126d 100644 (file)
@@ -2988,7 +2988,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:
@@ -3025,7 +3025,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;
@@ -3039,7 +3039,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;
@@ -3053,7 +3053,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;
@@ -3093,7 +3093,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;
@@ -3108,7 +3108,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
@@ -3141,7 +3141,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 */
@@ -3185,7 +3185,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) {
@@ -3213,7 +3213,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) {