Skip to content

Commit

Permalink
cppcheck: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkiDev committed Dec 16, 2020
1 parent 922ca91 commit 75c062a
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 128 deletions.
10 changes: 5 additions & 5 deletions IDE/GCC-ARM/Source/wolf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ unsigned int LowResTimer(void)
/* This is used by wolfCrypt benchmark tool only */
double current_time(int reset)
{
double time;
int timeMs = gTimeMs;
double timeNow;
int timeMs = gTimeMs;
(void)reset;
time = (timeMs / 1000); // sec
time += (double)(timeMs % 1000) / 1000; // ms
return time;
timeNow = (timeMs / 1000); // sec
timeNow += (double)(timeMs % 1000) / 1000; // ms
return timeNow;
}
#endif

Expand Down
9 changes: 5 additions & 4 deletions examples/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
err_sys("Client buffer malloc failed");
}
doExit:
if(tx_buffer) XFREE(tx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if(rx_buffer) XFREE(rx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (tx_buffer) XFREE(tx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (rx_buffer) XFREE(rx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
else {
err_sys("wolfSSL_connect failed");
Expand All @@ -701,10 +701,11 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
if (exitWithRet)
return err;

printf(
#if !defined(__MINGW32__)
printf("wolfSSL Client Benchmark %zu bytes\n"
"wolfSSL Client Benchmark %zu bytes\n"
#else
printf("wolfSSL Client Benchmark %d bytes\n"
"wolfSSL Client Benchmark %d bytes\n"
#endif
"\tConnect %8.3f ms\n"
"\tTX %8.3f ms (%8.3f MBps)\n"
Expand Down
23 changes: 12 additions & 11 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6591,25 +6591,26 @@ void FreeHandshakeResources(WOLFSSL* ssl)
int dtype;
#ifdef HAVE_ECC
dtype = DYNAMIC_TYPE_ECC;
#elif defined(HAVE_CURVE25519)
dtype = DYNAMIC_TYPE_CURVE25519;
#else
dtype = DYNAMIC_TYPE_CURVE448;
#endif
#ifdef HAVE_CURVE25519
#ifdef HAVE_ECC
#if defined(HAVE_ECC) && defined(HAVE_CURVE25519)
if (ssl->peerX25519KeyPresent ||
ssl->eccTempKeyPresent == DYNAMIC_TYPE_CURVE25519)
#endif /* HAVE_ECC */
{
dtype = DYNAMIC_TYPE_CURVE25519;
}
#endif /* HAVE_CURVE25519 */
#ifdef HAVE_CURVE448
#ifdef HAVE_ECC
#endif
#if (defined(HAVE_ECC) || defined(HAVE_CURVE25519)) && \
defined(HAVE_CURVE448)
if (ssl->peerX448KeyPresent ||
ssl->eccTempKeyPresent == DYNAMIC_TYPE_CURVE448)
#endif /* HAVE_ECC */
{
dtype = DYNAMIC_TYPE_CURVE448;
}
#endif /* HAVE_CURVE448 */
#endif
FreeKey(ssl, dtype, (void**)&ssl->eccTempKey);
ssl->eccTempKeyPresent = 0;
}
Expand Down Expand Up @@ -13066,16 +13067,16 @@ static WC_INLINE int DtlsCheckWindow(WOLFSSL* ssl)

#ifdef WOLFSSL_MULTICAST
static WC_INLINE word32 UpdateHighwaterMark(word32 cur, word32 first,
word32 second, word32 max)
word32 second, word32 high)
{
word32 newCur = 0;

if (cur < first)
newCur = first;
else if (cur < second)
newCur = second;
else if (cur < max)
newCur = max;
else if (cur < high)
newCur = high;

return newCur;
}
Expand Down
2 changes: 2 additions & 0 deletions src/sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3778,7 +3778,9 @@ static int DoHandShake(const byte* input, int* sslBytes,
break;
}

#ifdef HAVE_EXTENDED_MASTER
exit:
#endif
#ifdef HAVE_MAX_FRAGMENT
if (session->tlsFragBuf) {
XFREE(session->tlsFragBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
Expand Down
14 changes: 7 additions & 7 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,16 +1170,16 @@ int wolfSSL_mcast_get_max_peers(void)

#ifdef WOLFSSL_DTLS
static WC_INLINE word32 UpdateHighwaterMark(word32 cur, word32 first,
word32 second, word32 max)
word32 second, word32 high)
{
word32 newCur = 0;

if (cur < first)
newCur = first;
else if (cur < second)
newCur = second;
else if (cur < max)
newCur = max;
else if (cur < high)
newCur = high;

return newCur;
}
Expand Down Expand Up @@ -1505,7 +1505,7 @@ int wolfSSL_METHOD_GetObjectSize(void)

int wolfSSL_CTX_load_static_memory(WOLFSSL_CTX** ctx, wolfSSL_method_func method,
unsigned char* buf, unsigned int sz,
int flag, int max)
int flag, int maxSz)
{
WOLFSSL_HEAP* heap;
WOLFSSL_HEAP_HINT* hint;
Expand Down Expand Up @@ -1564,15 +1564,15 @@ int wolfSSL_CTX_load_static_memory(WOLFSSL_CTX** ctx, wolfSSL_method_func method

/* determine what max applies too */
if (flag & WOLFMEM_IO_POOL || flag & WOLFMEM_IO_POOL_FIXED) {
heap->maxIO = max;
heap->maxIO = maxSz;
}
else { /* general memory used in handshakes */
heap->maxHa = max;
heap->maxHa = maxSz;
}

heap->flag |= flag;

(void)max;
(void)maxSz;
(void)method;

return WOLFSSL_SUCCESS;
Expand Down
20 changes: 12 additions & 8 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,11 @@ int MakeTlsMasterSecret(WOLFSSL* ssl)
ssl->arrays->clientRandom,
ssl->arrays->serverRandom,
ssl->arrays->tsip_masterSecret);


#else

ret = NOT_COMPILED_IN;

#endif
} else
#endif
Expand Down Expand Up @@ -9027,18 +9031,18 @@ static int TLSX_EarlyData_GetSize(byte msgType, word16* pSz)
* Assumes that the the output buffer is big enough to hold data.
* In messages: ClientHello, EncryptedExtensions and NewSessionTicket.
*
* max The maximum early data size.
* maxSz The maximum early data size.
* output The buffer to write into.
* msgType The type of the message this extension is being written into.
* returns the number of bytes written into the buffer.
*/
static int TLSX_EarlyData_Write(word32 max, byte* output, byte msgType,
static int TLSX_EarlyData_Write(word32 maxSz, byte* output, byte msgType,
word16* pSz)
{
if (msgType == client_hello || msgType == encrypted_extensions)
return 0;
else if (msgType == session_ticket) {
c32toa(max, output);
c32toa(maxSz, output);
*pSz += OPAQUE32_LEN;
return 0;
}
Expand Down Expand Up @@ -9095,11 +9099,11 @@ static int TLSX_EarlyData_Parse(WOLFSSL* ssl, byte* input, word16 length,

/* Use the data to create a new Early Data object in the extensions.
*
* ssl The SSL/TLS object.
* max The maximum early data size.
* ssl The SSL/TLS object.
* maxSz The maximum early data size.
* returns 0 on success and other values indicate failure.
*/
int TLSX_EarlyData_Use(WOLFSSL* ssl, word32 max)
int TLSX_EarlyData_Use(WOLFSSL* ssl, word32 maxSz)
{
int ret = 0;
TLSX* extension;
Expand All @@ -9118,7 +9122,7 @@ int TLSX_EarlyData_Use(WOLFSSL* ssl, word32 max)
}

extension->resp = 1;
extension->val = max;
extension->val = maxSz;

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -5188,7 +5188,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
goto exit_scv;
}

if (args->length <= 0) {
if (args->length == 0) {
ERROR_OUT(NO_PRIVATE_KEY, exit_scv);
}

Expand Down
Loading

0 comments on commit 75c062a

Please sign in to comment.