Changes to clear issues raised by cppcheck

This commit is contained in:
Sean Parkinson
2020-01-15 22:15:38 +10:00
parent 3bdb7d8188
commit 55ea2facdd
63 changed files with 896 additions and 922 deletions
-4
View File
@@ -380,10 +380,7 @@ void wolfssl_server_test(uintData_t statusPtr)
int socketAddrLen=sizeof(sockaddr);
char rx_buf[RX_BUF_SIZE];
char tx_buf[TX_BUF_SIZE];
unsigned char attempt_conn;
clientConnectionHandleType TCPserverHandle;
void * sendBuffer;
DWORD bufferSizeInBytes;
WOLFSSL * ssl;
WOLFSSL_CTX * ctx;
@@ -572,7 +569,6 @@ int wolfsslRunTests (void)
{
thread_handle_t TCPhandle;
threadStatus ts;
int ret;
#if !defined(NO_CRYPT_TEST)
wolfcrypt_test(NULL);
+3 -3
View File
@@ -280,13 +280,13 @@ int mp_performance_check(int mul, int mulmod, int exptmod)
printf("(%d,%d) Xbits = %d, Ybits = %d Pbits = %d",
i , j, Xbits, Ybits, Pbits);
if(mul) {
printf(" mul = %llu (us)", elapsedTime1);
printf(" mul = %llu (us)", (unsigned long long)elapsedTime1);
}
if(mulmod) {
printf(" mulmod = %llu (us)\n", elapsedTime2);
printf(" mulmod = %llu (us)\n", (unsigned long long)elapsedTime2);
}
if(exptmod) {
printf(" exptmod = %llu (ms)\n", elapsedTime3);
printf(" exptmod = %llu (ms)\n", (unsigned long long)elapsedTime3);
}
}
}
+14 -14
View File
@@ -142,20 +142,20 @@ void HardFault_HandlerC( uint32_t *hardfault_args )
_BFAR = (*((volatile uint32_t *)(0xE000ED38)));
printf ("\n\nHard fault handler (all numbers in hex):\n");
printf ("R0 = %lx\n", stacked_r0);
printf ("R1 = %lx\n", stacked_r1);
printf ("R2 = %lx\n", stacked_r2);
printf ("R3 = %lx\n", stacked_r3);
printf ("R12 = %lx\n", stacked_r12);
printf ("LR [R14] = %lx subroutine call return address\n", stacked_lr);
printf ("PC [R15] = %lx program counter\n", stacked_pc);
printf ("PSR = %lx\n", stacked_psr);
printf ("CFSR = %lx\n", _CFSR);
printf ("HFSR = %lx\n", _HFSR);
printf ("DFSR = %lx\n", _DFSR);
printf ("AFSR = %lx\n", _AFSR);
printf ("MMAR = %lx\n", _MMAR);
printf ("BFAR = %lx\n", _BFAR);
printf ("R0 = %lx\n", (unsigned long)stacked_r0);
printf ("R1 = %lx\n", (unsigned long)stacked_r1);
printf ("R2 = %lx\n", (unsigned long)stacked_r2);
printf ("R3 = %lx\n", (unsigned long)stacked_r3);
printf ("R12 = %lx\n", (unsigned long)stacked_r12);
printf ("LR [R14] = %lx subroutine call return address\n", (unsigned long)stacked_lr);
printf ("PC [R15] = %lx program counter\n", (unsigned long)stacked_pc);
printf ("PSR = %lx\n", (unsigned long)stacked_psr);
printf ("CFSR = %lx\n", (unsigned long)_CFSR);
printf ("HFSR = %lx\n", (unsigned long)_HFSR);
printf ("DFSR = %lx\n", (unsigned long)_DFSR);
printf ("AFSR = %lx\n", (unsigned long)_AFSR);
printf ("MMAR = %lx\n", (unsigned long)_MMAR);
printf ("BFAR = %lx\n", (unsigned long)_BFAR);
// Break into the debugger
__asm("BKPT #0\n");
-1
View File
@@ -78,7 +78,6 @@ static int hash_firmware_verify_default(int numThreads)
int ret, i;
word32 idx;
double t;
char *sp_URI_value;
pthread_t threads[numThreads];
ecc_key eccKey[numThreads];
@@ -44,7 +44,7 @@ void InitTimer(void) {
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
printf("Clock=%dMHz\n", ui32SysClock/1000000) ;
printf("Clock=%dMHz\n", (int)(ui32SysClock/1000000));
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, -1);
+3 -3
View File
@@ -55,7 +55,7 @@ int wolfExample_TLSClient(const char* ip, int port)
int ret = 0;
WOLFSSL_CTX* ctx = NULL;
WOLFSSL* ssl = NULL; /* create WOLFSSL object */
int sockFd = -1; /* socket file descriptor */
int sockFd; /* socket file descriptor */
struct sockaddr_in servAddr; /* struct for server address */
char sendBuff[TLS_MAXDATASIZE], rcvBuff[TLS_MAXDATASIZE];
@@ -144,13 +144,13 @@ int wolfExample_TLSServer(int port)
int ret = 0;
WOLFSSL_CTX* ctx = NULL;
WOLFSSL* ssl = NULL;
int sockFd = -1, clientFd = -1;
int sockFd, clientFd = -1;
struct sockaddr_in serverAddr = {0}, clientAddr = {0};
const char reply[] = "I hear ya fa shizzle!\n";
int addrSize = sizeof(clientAddr);
char buff[256];
sockFd = socket(AF_INET, SOCK_STREAM, 0);
sockFd = socket(AF_INET, SOCK_STREAM, 0);
if (sockFd < 0) {
printf("Failed to create socket. Error: %d\n", errno);
return errno;
+1 -1
View File
@@ -436,7 +436,7 @@ static void for_command(void *args)
{
if( args == NULL || ((func_args *)args)->argc == 1) {
printf("For %d times\n", for_iteration) ;
} else if( args == NULL || ((func_args *)args)->argc == 2) {
} else if(((func_args *)args)->argc == 2) {
for_iteration = atoi(((func_args *)args)->argv[1]) ;
} else printf("Invalid argument\n") ;
}
@@ -69,7 +69,7 @@ char *inet_ntoa(struct in_addr in)
unsigned long inet_addr(const char *cp)
{
unsigned int a[4] ; unsigned long ret ;
sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]) ;
sscanf(cp, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]) ;
ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ;
return(ret) ;
}
+1 -1
View File
@@ -209,7 +209,7 @@ int main (void) {
snprintf(ver, VERSIZE, "%d", TLS_VER);
argv[6] = ver;
printf("SSL/TLS Client(%d)\n ", sizeof(argv)/sizeof(argv[0])) ;
printf("SSL/TLS Client(%d)\n ", (int)(sizeof(argv)/sizeof(argv[0]))) ;
printf(" Remote IP: %s, Port: %s\n Version: %s\n", argv[2], argv[4], verStr[TLS_VER]) ;
printf(" Other options: %s\n", OTHER_OPTIONS);
setTime((time_t)((RTC_YEAR-1970)*365*24*60*60) + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60);
+1 -1
View File
@@ -477,7 +477,7 @@ static void for_command(void *args)
{
if( args == NULL || ((func_args *)args)->argc == 1) {
printf("For %d times\n", for_iteration) ;
} else if( args == NULL || ((func_args *)args)->argc == 2) {
} else if(((func_args *)args)->argc == 2) {
for_iteration = atoi(((func_args *)args)->argv[1]) ;
} else printf("Invalid argument\n") ;
}
+1 -1
View File
@@ -1122,7 +1122,7 @@ int bench_tls(void* args)
{
int ret = 0;
info_t *info = NULL;
char *cipher, *next_cipher, *ciphers = NULL;
char *cipher, *next_cipher, *ciphers;
/* Runtime variables */
int argRuntimeSec = BENCH_RUNTIME_SEC;
+2 -2
View File
@@ -143,12 +143,12 @@ int main(void)
#ifdef USE_CLOCK_HZ
/* Speed up clock */
printf("SiFive HiFive1 Demo\n");
printf("Setting clock to %dMHz\n", USE_CLOCK_HZ/1000000);
printf("Setting clock to %dMHz\n", (int)(USE_CLOCK_HZ/1000000));
clk_Hz = metal_clock_set_rate_hz(
&__METAL_DT_SIFIVE_FE310_G000_PLL_HANDLE->clock, USE_CLOCK_HZ
);
#endif
printf("Actual Clock %dMHz\n", clk_Hz/1000000);
printf("Actual Clock %dMHz\n", (int)(clk_Hz/1000000));
/* Reconfigure the SPI Bus for dual mode */
#define QSPI0_CTRL 0x10014000UL
+3 -5
View File
@@ -154,14 +154,14 @@ static void hw_gpio_init(void)
static void hw_uart_init(void)
{
register uint16_t sbr, brfa;
uint8_t temp;
#ifdef FREESCALE_KSDK_BM
PORT_SetPinMux(UART_TX_PORT, UART_TX_PIN, UART_TX_MUX);
CLOCK_SetLpuartClock(1); /* MCGPLLCLK */
DbgConsole_Init((uint32_t)UART_PORT, UART_BAUD, DEBUG_CONSOLE_DEVICE_TYPE_LPUART, SYS_CLK_HZ);
#else
register uint16_t sbr, brfa;
uint8_t temp;
#ifdef WOLFSSL_FRDM_K64
/* Enable UART core clock ONLY for FRDM-K64F */
SIM->SCGC4 |= SIM_SCGC4_UART0_MASK;
@@ -217,8 +217,6 @@ static void hw_rtc_init(void)
/* Enable OSC */
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0) {
int i;
/* Turn on */
RTC->CR |= RTC_CR_OSCE_MASK;
+9 -10
View File
@@ -296,21 +296,20 @@ void join_thread(THREAD_TYPE thread)
int wolfssl_server_accept_tcp(WOLFSSL* ssl, SOCKET_T* fd, SOCKET_T* acceptfd)
{
int ret = 0;
SOCKET_T sockfd = WOLFSSL_SOCKET_INVALID;
SOCKET_T sockfd;
SOCKET_T clientfd = WOLFSSL_SOCKET_INVALID;
SOCKADDR_IN_T client;
socklen_t client_len = sizeof(client);
word16 port = 443;
struct sockaddr_in bind_addr;
if (ret == 0) {
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
bind_addr.sin_family = AF_INET;
bind_addr.sin_addr.s_addr = htonl(INADDR_ANY);
bind_addr.sin_port = htons(port);
if (bind(sockfd, (struct sockaddr *)&bind_addr, sizeof(bind_addr)) != 0)
ret = -1;
}
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
bind_addr.sin_family = AF_INET;
bind_addr.sin_addr.s_addr = htonl(INADDR_ANY);
bind_addr.sin_port = htons(port);
if (bind(sockfd, (struct sockaddr *)&bind_addr, sizeof(bind_addr)) != 0)
ret = -1;
if (ret == 0) {
*fd = sockfd;
printf("Server Listen\n");
@@ -507,6 +506,6 @@ int main()
printf("Done\n");
return (ret == 0) ? 0 : 1;
return 0;
}