]> git.ipfire.org Git - thirdparty/bind9.git/commit
Use switch instead of if when evaluating curves
authorOndřej Surý <ondrej@isc.org>
Mon, 20 Apr 2020 08:30:54 +0000 (10:30 +0200)
committerOndřej Surý <ondrej@isc.org>
Mon, 20 Apr 2020 09:40:42 +0000 (11:40 +0200)
commitcf30e7d0d1a0ff16569e76f210efbcefeface83e
tree650fb414edaf4c1aedc32041b459c88aca88beae
parentda38bd0e1d9739990fcbd582369698e81968ca62
Use switch instead of if when evaluating curves

Previously, the code would do:

    REQUIRE(alg == CURVE1 || alg == CURVE2);

    [...]

    if (alg == CURVE1) { /* code for CURVE1 */ }
    else { /* code for CURVE2 */ }

This approach is less extensible and also more prone to errors in case
the initial REQUIRE() is forgotten.  The code has been refactored to
use:

    REQUIRE(alg == CURVE1 || alg == CURVE2);

    [...]

    switch (alg) {
    case CURVE1: /* code for CURVE1 */; break;
    case CURVE2: /* code for CURVE2 */; break;
    default: INSIST(0);
    }
lib/dns/pkcs11ecdsa_link.c
lib/dns/pkcs11eddsa_link.c