From 3013a84bd1ff32f1eae23606c73d5a2e0bc13dd9 Mon Sep 17 00:00:00 2001 From: Todd A Ouska Date: Thu, 9 Jun 2011 17:11:20 -0700 Subject: [PATCH] fix default case warnings, add to warning list --- configure.in | 5 +++-- ctaocrypt/src/aes.c | 3 +++ include/cyassl_error.h | 1 + src/cyassl_int.c | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index dcefeeee5..c2f837b8a 100644 --- a/configure.in +++ b/configure.in @@ -465,7 +465,7 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIB_SOCKET_NSL dnl Various GCC warnings that should never fire for release quality code -GCCWARNINGS="-Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \ +GCCWARNINGS="-Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \ -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \ -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls \ @@ -473,7 +473,8 @@ GCCWARNINGS="-Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \ -Wmissing-field-initializers -Wdeclaration-after-statement \ -Wold-style-definition -Waddress -Wmissing-noreturn -Wnormalized=id \ -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds \ --Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wshadow" +-Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wshadow \ +-Wswitch-default" AC_ARG_ENABLE(gcc-lots-o-warnings, AS_HELP_STRING(--enable-gcc-lots-o-warnings, Enable lots of gcc warnings (default: disabled)), diff --git a/ctaocrypt/src/aes.c b/ctaocrypt/src/aes.c index ea282ec0a..cf07f134d 100644 --- a/ctaocrypt/src/aes.c +++ b/ctaocrypt/src/aes.c @@ -922,6 +922,9 @@ int AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv, rk += 8; } break; + + default: + return BAD_FUNC_ARG; } if (dir == AES_DECRYPTION) diff --git a/include/cyassl_error.h b/include/cyassl_error.h index 96ac9c878..b522faf4f 100644 --- a/include/cyassl_error.h +++ b/include/cyassl_error.h @@ -31,6 +31,7 @@ #endif enum CyaSSL_ErrorCodes { + INPUT_CASE_ERROR = -201, /* process input state error */ PREFIX_ERROR = -202, /* bad index to key rounds */ MEMORY_ERROR = -203, /* out of memory */ VERIFY_FINISHED_ERROR = -204, /* verify problem on finished */ diff --git a/src/cyassl_int.c b/src/cyassl_int.c index cc7f5662d..b8fdb4db0 100644 --- a/src/cyassl_int.c +++ b/src/cyassl_int.c @@ -1089,6 +1089,9 @@ retry: case IO_ERR_CONN_CLOSE: /* peer closed connection */ ssl->options.isClosed = 1; return -1; + + default: + return recvd; } return recvd; @@ -1168,6 +1171,9 @@ int SendBuffered(SSL* ssl) case IO_ERR_CONN_CLOSE: /* epipe / conn closed, same as reset */ ssl->options.connReset = 1; break; + + default: + return SOCKET_ERROR_E; } return SOCKET_ERROR_E; @@ -1827,6 +1833,9 @@ static INLINE void Encrypt(SSL* ssl, byte* out, const byte* input, word32 sz) RabbitProcess(&ssl->encrypt.rabbit, out, input, sz); break; #endif + + default: + CYASSL_MSG("CyaSSL Encrypt programming error"); } } @@ -1863,6 +1872,9 @@ static INLINE void Decrypt(SSL* ssl, byte* plain, const byte* input, word32 sz) RabbitProcess(&ssl->decrypt.rabbit, plain, input, sz); break; #endif + + default: + CYASSL_MSG("CyaSSL Decrypt programming error"); } } @@ -2310,6 +2322,9 @@ int ProcessReply(SSL* ssl) ssl->options.processReply = doProcessInit; continue; } + default: + CYASSL_MSG("Bad process input state, programming error"); + return INPUT_CASE_ERROR; } } } @@ -2972,6 +2987,10 @@ void SetErrorString(int error, char* str) XSTRNCPY(str, "unsupported cipher suite", max); break; + case INPUT_CASE_ERROR : + XSTRNCPY(str, "input state error", max); + break; + case PREFIX_ERROR : XSTRNCPY(str, "bad index to key rounds", max); break;