]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: ssl: remove poorly readable nested ternary
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 14 Aug 2020 13:30:13 +0000 (15:30 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 14 Aug 2020 13:47:48 +0000 (15:47 +0200)
Replace a four level nested ternary expression by an if/else expression
in ssl_sock_switchctx_cbk()

src/ssl_sock.c

index aabd861c5830f36c187a373f188bd3f435814c41..b9d88b1c42fc4400d167fd15e87d7503390a5458 100644 (file)
@@ -2384,12 +2384,17 @@ static int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
        /* Once the certificates are found, select them depending on what is
         * supported in the client and by key_signature priority order: EDSA >
         * RSA > DSA */
-       node = (has_ecdsa_sig && node_ecdsa) ? node_ecdsa
-               : ((has_rsa_sig && node_rsa) ? node_rsa
-                  : (node_anonymous ? node_anonymous
-                     : (node_ecdsa ? node_ecdsa      /* no ecdsa signature case (< TLSv1.2) */
-                        : node_rsa                   /* no rsa signature case (far far away) */
-                       )));
+       if (has_ecdsa_sig && node_ecdsa)
+               node = node_ecdsa;
+       else if (has_rsa_sig && node_rsa)
+               node = node_rsa;
+       else if (node_anonymous)
+               node = node_anonymous;
+       else if (node_ecdsa)
+               node = node_ecdsa;      /* no ecdsa signature case (< TLSv1.2) */
+       else
+               node = node_rsa;        /* no rsa signature case (far far away) */
+
        if (node) {
                /* switch ctx */
                struct ssl_bind_conf *conf = container_of(node, struct sni_ctx, name)->conf;