intel / intel-ipsec-mb

Intel(R) Multi-Buffer Crypto for IPSec
BSD 3-Clause "New" or "Revised" License
292 stars 88 forks source link

dead code warnings from static analysis on test/api_test.c #77

Closed ColinIanKing closed 3 years ago

ColinIanKing commented 3 years ago

Maybe a false positive, but I'm seeing some static analysis warnings in test/api_test.c

735                                if (hash == IMB_AUTH_GCM_SGL)
   CID 113775 (#3 of 4): Logically dead code (DEADCODE) [select issue]
736                                        template_job.sgl_state = IMB_SGL_UPDATE;
737
   at_most: When switching on hash, the value of hash must be at most 44.
738                                switch (hash) {
739                                case IMB_AUTH_ZUC_EIA3_BITLEN:
740                                case IMB_AUTH_ZUC256_EIA3_BITLEN:
741                                        /* (2^32) - 32 is max */
742                                        template_job.msg_len_to_hash_in_bytes =
743                                                ((1ULL << 32) - 31);
744                                        break;
745                                case IMB_AUTH_SNOW3G_UIA2_BITLEN:
746                                        /* (2^32) is max */
747                                        template_job.msg_len_to_hash_in_bits =
748                                                ((1ULL << 32) + 1);
749                                        break;
750                                case IMB_AUTH_KASUMI_UIA1:
751                                        /* 20000 bits (2500 bytes) is max */
752                                        template_job.msg_len_to_hash_in_bytes =
753                                                (20008 / 8); /* 2501 bytes */
754                                        break;
   CID 113775 (#2 of 4): Logically dead code (DEADCODE)
   dead_error_condition: The switch governing value hash cannot be IMB_AUTH_CHACHA20_POLY1305.
755                                case IMB_AUTH_CHACHA20_POLY1305:
   dead_error_condition: The switch governing value hash cannot be IMB_AUTH_CHACHA20_POLY1305_SGL.
   CID 113775 (#4 of 4): Logically dead code (DEADCODE)
    dead_error_begin: Execution cannot reach this statement: case IMB_AUTH_CHACHA20_POLY....
756                                case IMB_AUTH_CHACHA20_POLY1305_SGL:
757                                        /* CHACHA20 limit (2^32 - 1) x 64 */
758                                        template_job.msg_len_to_hash_in_bytes =
759                                                ((1ULL << 38) - 64) + 1;
760                                        break;
761                                default:
762                                        template_job.msg_len_to_hash_in_bytes =
763                                                ((1 << 16) - 1);
764                                        break;
765                                }
766                                if (!is_submit_invalid(mb_mgr, &template_job,
767                                                  TEST_AUTH_MSG_LEN_GT_MAX,
768                                                  IMB_ERR_JOB_AUTH_LEN))
769                                        return 1;
770                                printf(".");
771                        }