From: James Jones Date: Fri, 29 Apr 2022 12:34:30 +0000 (-0500) Subject: Remove needless NULL checks in cf_pair_parse_internal() (CID #1469127, #1469144)... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45a278f2fa4e5fbbb3916ee1cd1e7a0930452d01;p=thirdparty%2Ffreeradius-server.git Remove needless NULL checks in cf_pair_parse_internal() (CID #1469127, #1469144) (#4476) array is checked for NULL, and an error returned if it is, before the loop that fills the array, so the checks of it in the loop (and also of entry, which can't be NULL either). --- diff --git a/src/lib/server/cf_parse.c b/src/lib/server/cf_parse.c index 1e0b6413ed1..c3471472bbf 100644 --- a/src/lib/server/cf_parse.c +++ b/src/lib/server/cf_parse.c @@ -702,7 +702,6 @@ static int CC_HINT(nonnull(4,5)) cf_pair_parse_internal(TALLOC_CTX *ctx, void *o */ if (!out) { if (!rule->func) { - no_out: cf_log_err(cs, "Rule doesn't specify output destination"); return -1; } @@ -773,14 +772,12 @@ static int CC_HINT(nonnull(4,5)) cf_pair_parse_internal(TALLOC_CTX *ctx, void *o int ret; cf_parse_t func; void *entry; - TALLOC_CTX *value_ctx = array ? array : ctx; + TALLOC_CTX *value_ctx = array; /* * Figure out where to write the output */ - if (!array) { - entry = NULL; - } else if ((FR_BASE_TYPE(type) == FR_TYPE_VOID) || (type & FR_TYPE_TMPL)) { + if ((FR_BASE_TYPE(type) == FR_TYPE_VOID) || (type & FR_TYPE_TMPL)) { entry = &array[i]; } else { entry = ((uint8_t *) array) + (i * fr_value_box_field_sizes[FR_BASE_TYPE(type)]); @@ -795,7 +792,6 @@ static int CC_HINT(nonnull(4,5)) cf_pair_parse_internal(TALLOC_CTX *ctx, void *o cp->attr, cp->value); func = rule->func; } else { - if (!entry) goto no_out; func = cf_pair_parse_value; }