Silence uninitialized value false positives

In base32_decode_char the GCC 12 static analyser fails to determine
that ctx->val[1], ctx->val[3], ctx->val[4] and ctx->val[6] are
assigned values by the previous call to base32_decode_char.  Initialise
ctx->val to zeros when initalising the rest of ctx to silence the
false positive.
This commit is contained in:
Mark Andrews
2023-03-08 15:16:44 +11:00
parent 700d5f6b0b
commit 0045b24500

View File

@@ -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));