In no fewer than four places the same switch statement was used to figure out what kind of hash to read from the bincode input.
U3JWO63YYQDCJX7CWXCS3N26CHY2TASADTCQIEDSJ7WC25GLZD5QC
WFA5BBRFVUHJ53MOPZ2WDXZ4CEHKA32LDYERSYLVETIZTZDW22GAC
RIWSVVASWLJQQTSVRHIIUPENOZWOMHQLZMTQVGJUS2ZUGDPSWWIQC
OBKF6SIIFFHHY7YWKPPX75N23NAVUD5662DKIHXSSIDPKKXQ5ZDQC
Q7TKZCJP2Z75EICZYKCEZDHKGERSOKZGMTSU3UXETBHTF663T66AC
FMYCPGKDAPOUFLQOCXXKZ6TR75HT3TNCG4X3GAJDM4ARWKNWOSWAC
ZKAOPMCHBGP7J7NQB233AQJQDX6TBD7REPLF3KN3EIKZK6TZZMBQC
JAGXXSR7DR5FG77VKBF62BW7Q3JMVHCLHF4VB2PSLIZF4RLE553QC
}
static void
change_readhash(Bincode *binstat, uint8_t *dest, uint8_t variant)
{
switch (variant) {
case HASH_BLAKE3:
bincode_getbytes(binstat, dest, BLAKE3_BYTES);
break;
case HASH_NONE:
/* Do nothing - no bytes to consume */
break;
default:
die("unknown hash variant: %u", variant);
}
switch (target->entries[i].variant) {
case HASH_BLAKE3:
bincode_getbytes(
binstat, target->entries[i].bytes, BLAKE3_BYTES
);
break;
case HASH_NONE:
/* Do nothing, no bytes to consume */
break;
default:
abort();
}
change_readhash(
binstat, target->entries[i].bytes,
target->entries[i].variant
);
switch (pos->change.variant) {
case HASH_BLAKE3:
bincode_getbytes(
binstat, (uint8_t *)&pos->change.bytes,
BLAKE3_BYTES
);
break;
case HASH_NONE:
break;
default:
abort();
}
change_readhash(
binstat, (uint8_t *)&pos->change.bytes,
pos->change.variant
);
switch (hash->variant) {
case HASH_BLAKE3:
bincode_getbytes(
binstat, (uint8_t *)hash->bytes, BLAKE3_BYTES
);
break;
case HASH_NONE:
break;
default:
abort();
}
change_readhash(binstat, (uint8_t *)hash->bytes, hash->variant);