From: Alan T. DeKok Date: Fri, 19 Nov 2021 15:05:32 +0000 (-0500) Subject: more used / unused X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=090990e2ae287d19902363179ef2451a100ed114;p=thirdparty%2Ffreeradius-server.git more used / unused when we cast to a fixed-size leaf type, we never allocate memory. --- diff --git a/src/lib/util/calc.c b/src/lib/util/calc.c index 6ab60c44ab9..780b22ef799 100644 --- a/src/lib/util/calc.c +++ b/src/lib/util/calc.c @@ -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] = {