Use switch instead of multiple ifs
authorAlessandro Ghedini <alessandro@ghedini.me>
Tue, 13 Sep 2016 23:51:02 +0000 (00:51 +0100)
committerRich Salz <rsalz@openssl.org>
Fri, 16 Sep 2016 15:07:08 +0000 (11:07 -0400)
Makes the logic a little bit clearer.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1571)

ssl/statem/statem.c

index 3df4ce61e110a807c9df30b0abaf687089b14ae9..df3008575d19604ad0f3702f7ff489d3ac0d69dd 100644 (file)
@@ -566,22 +566,24 @@ static SUB_STATE_RETURN read_state_machine(SSL *s)
             /* Discard the packet data */
             s->init_num = 0;
 
             /* Discard the packet data */
             s->init_num = 0;
 
-            if (ret == MSG_PROCESS_ERROR) {
+            switch (ret) {
+            case MSG_PROCESS_ERROR:
                 return SUB_STATE_ERROR;
                 return SUB_STATE_ERROR;
-            }
 
 
-            if (ret == MSG_PROCESS_FINISHED_READING) {
+            case MSG_PROCESS_FINISHED_READING:
                 if (SSL_IS_DTLS(s)) {
                     dtls1_stop_timer(s);
                 }
                 return SUB_STATE_FINISHED;
                 if (SSL_IS_DTLS(s)) {
                     dtls1_stop_timer(s);
                 }
                 return SUB_STATE_FINISHED;
-            }
 
 
-            if (ret == MSG_PROCESS_CONTINUE_PROCESSING) {
+            case MSG_PROCESS_CONTINUE_PROCESSING:
                 st->read_state = READ_STATE_POST_PROCESS;
                 st->read_state_work = WORK_MORE_A;
                 st->read_state = READ_STATE_POST_PROCESS;
                 st->read_state_work = WORK_MORE_A;
-            } else {
+                break;
+
+            default:
                 st->read_state = READ_STATE_HEADER;
                 st->read_state = READ_STATE_HEADER;
+                break;
             }
             break;
 
             }
             break;