]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more used / unused
authorAlan T. DeKok <aland@freeradius.org>
Fri, 19 Nov 2021 15:05:32 +0000 (10:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 19 Nov 2021 20:36:58 +0000 (15:36 -0500)
when we cast to a fixed-size leaf type, we never allocate
memory.

src/lib/util/calc.c

index 6ab60c44ab975ee0f13c6e4a64008e37c3dd8353..780b22ef79915b276122368de78ffeab6f0f1b1e 100644 (file)
@@ -217,7 +217,7 @@ static const fr_type_t upcast[FR_TYPE_MAX + 1][FR_TYPE_MAX + 1] = {
 };
 
 
-static int calc_date(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *a, fr_token_t op, fr_value_box_t const *b)
+static int calc_date(UNUSED TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *a, fr_token_t op, fr_value_box_t const *b)
 {
        fr_value_box_t one, two;
        bool overflow;
@@ -235,12 +235,12 @@ static int calc_date(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const
         *      Cast dates to time delta, do the conversions.
         */
        if (a->type != FR_TYPE_TIME_DELTA) {
-               if (fr_value_box_cast(ctx, &one, FR_TYPE_TIME_DELTA, NULL, a) < 0) return -1;
+               if (fr_value_box_cast(NULL, &one, FR_TYPE_TIME_DELTA, NULL, a) < 0) return -1;
                a = &one;
        }
 
        if (b->type != FR_TYPE_TIME_DELTA) {
-               if (fr_value_box_cast(ctx, &two, FR_TYPE_TIME_DELTA, NULL, b) < 0) return -1;
+               if (fr_value_box_cast(NULL, &two, FR_TYPE_TIME_DELTA, NULL, b) < 0) return -1;
                b = &two;
        }
 
@@ -266,7 +266,7 @@ static int calc_date(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const
        return 0;
 }
 
-static int calc_time_delta(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *a, fr_token_t op, fr_value_box_t const *b)
+static int calc_time_delta(UNUSED TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t const *a, fr_token_t op, fr_value_box_t const *b)
 {
        fr_value_box_t one, two;
 
@@ -288,12 +288,12 @@ static int calc_time_delta(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t
         *      TIME_DELTA.
         */
        if (a->type == FR_TYPE_DATE) {
-               if (fr_value_box_cast(ctx, &one, FR_TYPE_TIME_DELTA, NULL, a) < 0) return -1;
+               if (fr_value_box_cast(NULL, &one, FR_TYPE_TIME_DELTA, NULL, a) < 0) return -1;
                a = &one;
        }
 
        if (b->type == FR_TYPE_DATE) {
-               if (fr_value_box_cast(ctx, &two, FR_TYPE_TIME_DELTA, NULL, b) < 0) return -1;
+               if (fr_value_box_cast(NULL, &two, FR_TYPE_TIME_DELTA, NULL, b) < 0) return -1;
                b = &two;
        }
 
@@ -301,12 +301,12 @@ static int calc_time_delta(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t
         *      We cast the inputs based on the destination time resolution.  So "5ms + 5" = "10ms".
         */
        if (a->type != FR_TYPE_TIME_DELTA) {
-               if (fr_value_box_cast(ctx, &one, FR_TYPE_TIME_DELTA, dst->enumv, a) < 0) return -1;
+               if (fr_value_box_cast(NULL, &one, FR_TYPE_TIME_DELTA, dst->enumv, a) < 0) return -1;
                a = &one;
        }
 
        if (b->type != FR_TYPE_TIME_DELTA) {
-               if (fr_value_box_cast(ctx, &two, FR_TYPE_TIME_DELTA, dst->enumv, b) < 0) return -1;
+               if (fr_value_box_cast(NULL, &two, FR_TYPE_TIME_DELTA, dst->enumv, b) < 0) return -1;
                b = &two;
        }
 
@@ -660,12 +660,12 @@ static int calc_float32(UNUSED TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_bo
         *      Intermediate calculations are done using increased precision.
         */
        if (a->type != FR_TYPE_FLOAT64) {
-               if (fr_value_box_cast(ctx, &one, FR_TYPE_FLOAT64, NULL, a) < 0) return -1;
+               if (fr_value_box_cast(NULL, &one, FR_TYPE_FLOAT64, NULL, a) < 0) return -1;
                a = &one;
        }
 
        if (b->type != FR_TYPE_FLOAT64) {
-               if (fr_value_box_cast(ctx, &two, FR_TYPE_FLOAT64, NULL, b) < 0) return -1;
+               if (fr_value_box_cast(NULL, &two, FR_TYPE_FLOAT64, NULL, b) < 0) return -1;
                b = &two;
        }
 
@@ -695,12 +695,12 @@ static int calc_float64(UNUSED TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_bo
        fr_assert(dst->type == FR_TYPE_FLOAT64);
 
        if (a->type != FR_TYPE_FLOAT64) {
-               if (fr_value_box_cast(ctx, &one, FR_TYPE_FLOAT64, NULL, a) < 0) return -1;
+               if (fr_value_box_cast(NULL, &one, FR_TYPE_FLOAT64, NULL, a) < 0) return -1;
                a = &one;
        }
 
        if (b->type != FR_TYPE_FLOAT64) {
-               if (fr_value_box_cast(ctx, &two, FR_TYPE_FLOAT64, NULL, b) < 0) return -1;
+               if (fr_value_box_cast(NULL, &two, FR_TYPE_FLOAT64, NULL, b) < 0) return -1;
                b = &two;
        }
 
@@ -816,12 +816,12 @@ static int calc_integer(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t con
        }
 
        if (a->type != type) {
-               if (fr_value_box_cast(ctx, &one, type, NULL, a) < 0) return -1;
+               if (fr_value_box_cast(NULL, &one, type, NULL, a) < 0) return -1;
                a = &one;
        }
 
        if (b->type != type) {
-               if (fr_value_box_cast(ctx, &two, type, NULL, b) < 0) return -1;
+               if (fr_value_box_cast(NULL, &two, type, NULL, b) < 0) return -1;
                b = &two;
        }
 
@@ -843,14 +843,14 @@ static int calc_integer(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t con
        }
 
        fr_value_box_init(&out, type, dst->enumv, false);
-       rcode = calc(ctx, &out, a, op, b);
+       rcode = calc(NULL, &out, a, op, b);
        if (rcode < 0) return rcode;
 
        /*
         *      Then once we're done, cast the result to the final
         *      output type.
         */
-       return fr_value_box_cast(ctx, dst, dst->type, dst->enumv, &out);
+       return fr_value_box_cast(NULL, dst, dst->type, dst->enumv, &out);
 }
 
 static const fr_binary_op_t calc_type[FR_TYPE_MAX + 1] = {