Merge pull request #72 from ejohnstown/static-fixes

fix a handful of clang static analysis warnings
pull/74/head
JacobBarthelmeh 2018-06-07 09:38:46 -06:00 committed by GitHub
commit 0fc6f343b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -564,8 +564,6 @@ THREAD_RETURN WOLFSSH_THREAD server_test(void* args)
byte buf[SCRATCH_BUFFER_SZ];
word32 bufSz;
bufName = useEcc ? "./keys/server-key-ecc.der" :
"./keys/server-key-rsa.der" ;
bufSz = load_key(useEcc, buf, SCRATCH_BUFFER_SZ);
if (bufSz == 0) {
fprintf(stderr, "Couldn't load key.\n");

View File

@ -1038,9 +1038,11 @@ int ChannelRemove(WOLFSSH* ssh, word32 channel, byte peer)
if (ssh == NULL)
ret = WS_BAD_ARGUMENT;
if (ret == WS_SUCCESS) {
list = ssh->channelList;
if (list == NULL)
ret = WS_INVALID_CHANID;
}
if (ret == WS_SUCCESS) {
WOLFSSH_CHANNEL* prev = NULL;

View File

@ -397,7 +397,8 @@ static int test_Errors(void)
#else
int i, j = 0;
/* Values that are not or no longer error codes. */
int missing[] = { WS_SUCCESS };
int missing[] = { 0 };
int missingSz = (int)sizeof(missing)/sizeof(missing[0]);
/* Check that all errors have a string and it's the same through the two
* APIs. Check that the values that are not errors map to the unknown
@ -405,15 +406,15 @@ static int test_Errors(void)
for (i = WS_SUCCESS; i >= WS_LAST_E; i--) {
errStr = wolfSSH_ErrorToName(i);
if (i != missing[j]) {
if (errStr == unknownStr) {
if (j < missingSz && i == missing[j]) {
j++;
if (errStr != unknownStr) {
result = -105;
break;
}
}
else {
j++;
if (errStr != unknownStr) {
if (errStr == unknownStr) {
result = -106;
break;
}