diff --git a/lib/isc/base32.c b/lib/isc/base32.c index 90c37c75f6..ce6db733e4 100644 --- a/lib/isc/base32.c +++ b/lib/isc/base32.c @@ -149,18 +149,6 @@ typedef struct { bool pad; /*%< Expect padding */ } base32_decode_ctx_t; -static void -base32_decode_init(base32_decode_ctx_t *ctx, int length, const char base[], - bool pad, isc_buffer_t *target) { - ctx->digits = 0; - ctx->seen_end = false; - ctx->seen_32 = 0; - ctx->length = length; - ctx->target = target; - ctx->base = base; - ctx->pad = pad; -} - static isc_result_t base32_decode_char(base32_decode_ctx_t *ctx, int c) { const char *s; @@ -293,15 +281,15 @@ static isc_result_t base32_tobuffer(isc_lex_t *lexer, const char base[], bool pad, isc_buffer_t *target, int length) { unsigned int before, after; - base32_decode_ctx_t ctx; + base32_decode_ctx_t ctx = { + .length = length, .base = base, .target = target, .pad = pad + }; isc_textregion_t *tr; isc_token_t token; bool eol; REQUIRE(length >= -2); - base32_decode_init(&ctx, length, base, pad, target); - before = isc_buffer_usedlength(target); while (!ctx.seen_end && (ctx.length != 0)) { unsigned int i; @@ -350,9 +338,10 @@ isc_base32hexnp_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) { static isc_result_t base32_decodestring(const char *cstr, const char base[], bool pad, isc_buffer_t *target) { - base32_decode_ctx_t ctx; + base32_decode_ctx_t ctx = { + .length = -1, .base = base, .target = target, .pad = pad + }; - base32_decode_init(&ctx, -1, base, pad, target); for (;;) { int c = *cstr++; if (c == '\0') { @@ -385,9 +374,10 @@ isc_base32hexnp_decodestring(const char *cstr, isc_buffer_t *target) { static isc_result_t base32_decoderegion(isc_region_t *source, const char base[], bool pad, isc_buffer_t *target) { - base32_decode_ctx_t ctx; + base32_decode_ctx_t ctx = { + .length = -1, .base = base, .target = target, .pad = pad + }; - base32_decode_init(&ctx, -1, base, pad, target); while (source->length != 0) { int c = *source->base; RETERR(base32_decode_char(&ctx, c));