From b845f19a3bb200e49a7a314787b3290e3155ce01 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 25 Nov 2014 14:51:10 -0600 Subject: Fixes for more cppcheck complaints. Mostly cosmetic --- apps/examples/adc/adc_main.c | 4 ++-- apps/examples/bridge/bridge_main.c | 4 ++-- apps/examples/cc3000/cc3000basic.c | 16 +++++++++------- apps/examples/ostest/aio.c | 4 ++-- apps/examples/ostest/rmutex.c | 2 +- apps/examples/poll/poll_listener.c | 3 ++- apps/examples/poll/poll_main.c | 3 ++- apps/examples/romfs/romfs_main.c | 3 ++- apps/examples/slcd/slcd_main.c | 2 +- apps/examples/smart/smart_main.c | 2 +- apps/examples/touchscreen/tc_main.c | 4 ++-- apps/examples/usbserial/host.c | 4 ++-- apps/examples/usbserial/usbserial_main.c | 4 ++-- apps/examples/wgetjson/wgetjson_main.c | 22 ++++++++++++++-------- 14 files changed, 44 insertions(+), 33 deletions(-) diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c index 884598b6d..3478b5e0a 100644 --- a/apps/examples/adc/adc_main.c +++ b/apps/examples/adc/adc_main.c @@ -358,8 +358,8 @@ int adc_main(int argc, char *argv[]) int nsamples = nbytes / sizeof(struct adc_msg_s); if (nsamples * sizeof(struct adc_msg_s) != nbytes) { - printf("adc_main: read size=%d is not a multiple of sample size=%d, Ignoring\n", - nbytes, sizeof(struct adc_msg_s)); + printf("adc_main: read size=%ld is not a multiple of sample size=%d, Ignoring\n", + (long)nbytes, sizeof(struct adc_msg_s)); } else { diff --git a/apps/examples/bridge/bridge_main.c b/apps/examples/bridge/bridge_main.c index 0c2534f93..f296db899 100644 --- a/apps/examples/bridge/bridge_main.c +++ b/apps/examples/bridge/bridge_main.c @@ -484,8 +484,8 @@ static int bridge_net1_worker(int argc, char *argv[]) } else if (nsent != nrecvd) { - fprintf(stderr, "NET1 ERROR: Bad send length: %d Expected: %ld\n", - nsent, (long)nrecvd); + fprintf(stderr, "NET1 ERROR: Bad send length: %ld Expected: %ld\n", + (long)nsent, (long)nrecvd); goto errout_with_sendsd; } } diff --git a/apps/examples/cc3000/cc3000basic.c b/apps/examples/cc3000/cc3000basic.c index 544e565b9..e1b17f8b4 100644 --- a/apps/examples/cc3000/cc3000basic.c +++ b/apps/examples/cc3000/cc3000basic.c @@ -512,7 +512,7 @@ void StartSmartConfig(void) printf("Starting Smart Config\n"); printf(" Disabling auto-connect policy..."); - if ((rval = wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE)) !=0 ) + if ((rval = wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE)) !=0) { printf(" Failed!\n Setting auto connection policy failed, error: %lx\n", (unsigned long)rval); @@ -523,7 +523,7 @@ void StartSmartConfig(void) printf(" Deleting all existing profiles..."); fflush(stdout); - if ((rval = wlan_ioctl_del_profile(255)) !=0 ) + if ((rval = wlan_ioctl_del_profile(255)) !=0) { printf(" Failed!\n Deleting all profiles failed, error: %lx\n", (unsigned long)rval); @@ -536,7 +536,7 @@ void StartSmartConfig(void) printf(" Setting smart config prefix..."); fflush(stdout); - if ((rval = wlan_smart_config_set_prefix(simpleConfigPrefix)) !=0 ) + if ((rval = wlan_smart_config_set_prefix(simpleConfigPrefix)) !=0) { printf(" Failed!\n Setting smart config prefix failed, error: %lx", (unsigned long)rval); @@ -547,7 +547,7 @@ void StartSmartConfig(void) printf(" Starting smart config..."); fflush(stdout); - if ((rval = wlan_smart_config_start(0)) !=0 ) + if ((rval = wlan_smart_config_start(0)) !=0) { printf(" Failed!\n Starting smart config failed, error: %lx\n", (unsigned long)rval); @@ -565,9 +565,11 @@ void StartSmartConfig(void) printf(" Enabling auto-connect policy..."); fflush(stdout); - if ((rval=wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE)) !=0 ) + + if ((rval = wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE)) !=0) { - printf(" Failed!\n Setting auto connection policy failed, error: %x\n", rval); + printf(" Failed!\n Setting auto connection policy failed, error: %lx\n", + (unsigned long)rval); return; } @@ -887,7 +889,7 @@ void ListAccessPoints(void) if (--apCounter>0) { - if ((rval=wlan_ioctl_get_scan_results(2000, (uint8_t *)&sr)) !=0 ) + if ((rval=wlan_ioctl_get_scan_results(2000, (uint8_t *)&sr)) !=0) { printf(" Got back unusual result from wlan_ioctl_get scan, can't continue: %d\n", rval); return; diff --git a/apps/examples/ostest/aio.c b/apps/examples/ostest/aio.c index 68b94228f..5313c55a6 100644 --- a/apps/examples/ostest/aio.c +++ b/apps/examples/ostest/aio.c @@ -571,7 +571,7 @@ void aio_test(void) goto errout_with_fildes; } - printf(" aio_cancel return %d\n"); + printf(" aio_cancel return %d\n", ret); do { @@ -614,7 +614,7 @@ void aio_test(void) goto errout_with_fildes; } - printf(" aio_cancel return %d\n"); + printf(" aio_cancel return %d\n", ret); do { diff --git a/apps/examples/ostest/rmutex.c b/apps/examples/ostest/rmutex.c index 5456cddb7..62c64d48f 100644 --- a/apps/examples/ostest/rmutex.c +++ b/apps/examples/ostest/rmutex.c @@ -156,7 +156,7 @@ void recursive_mutex_test(void) { printf("recursive_mutex_test: Waiting for thread %d\n", i+1); #ifdef SDCC - pthread_join(thread[i], &result1); + pthread_join(thread[i], &result[i]); #else pthread_join(thread[i], NULL); #endif diff --git a/apps/examples/poll/poll_listener.c b/apps/examples/poll/poll_listener.c index 23272d0a5..ca1b1542d 100644 --- a/apps/examples/poll/poll_listener.c +++ b/apps/examples/poll/poll_listener.c @@ -242,7 +242,8 @@ void *poll_listener(pthread_addr_t pvarg) } buffer[nbytes] = '\0'; - printf("poll_listener: Read[%d] '%s' (%d bytes)\n", i, buffer, nbytes); + printf("poll_listener: Read[%d] '%s' (%ld bytes)\n", + i, buffer, (long)nbytes); } /* Suppress error report if no read data on the next time through */ diff --git a/apps/examples/poll/poll_main.c b/apps/examples/poll/poll_main.c index 11479e1a3..0f61f2f25 100644 --- a/apps/examples/poll/poll_main.c +++ b/apps/examples/poll/poll_main.c @@ -199,7 +199,8 @@ int poll_main(int argc, char *argv[]) goto errout; } - printf("\npoll_main: Sent '%s' (%d bytes)\n", buffer, nbytes); + printf("\npoll_main: Sent '%s' (%ld bytes)\n", + buffer, (long)nbytes); fflush(stdout); /* Wait awhile. This delay should be long enough that the diff --git a/apps/examples/romfs/romfs_main.c b/apps/examples/romfs/romfs_main.c index 2cb5475a4..ce1c53d60 100644 --- a/apps/examples/romfs/romfs_main.c +++ b/apps/examples/romfs/romfs_main.c @@ -307,7 +307,8 @@ static void checkfile(const char *path, struct node_s *node) } else if (nbytesread != node->size) { - printf(" -- ERROR: Read %d bytes, expected %d\n", nbytesread, node->size); + printf(" -- ERROR: Read %ld bytes, expected %lu\n", + (long)nbytesread, (unsigned long)node->size); g_nerrors++; } else if (memcmp(g_scratchbuffer, node->u.filecontent, node->size) != 0) diff --git a/apps/examples/slcd/slcd_main.c b/apps/examples/slcd/slcd_main.c index be10969d4..70a91950b 100644 --- a/apps/examples/slcd/slcd_main.c +++ b/apps/examples/slcd/slcd_main.c @@ -317,7 +317,7 @@ int slcd_main(int argc, char *argv[]) /* Set the brightness to the mid value */ brightness = ((unsigned long)priv->attr.maxbrightness + 1) >> 1; - printf("Set brightness to %ld\n", brightness); + printf("Set brightness to %lu\n", brightness); ret = ioctl(fd, SLCDIOC_SETBRIGHTNESS, brightness); if (ret < 0) diff --git a/apps/examples/smart/smart_main.c b/apps/examples/smart/smart_main.c index 83585cba4..d9e1819b5 100644 --- a/apps/examples/smart/smart_main.c +++ b/apps/examples/smart/smart_main.c @@ -552,7 +552,7 @@ static inline int smart_rdfile(FAR struct smart_filedesc_s *file) printf("ERROR: Read past the end of file\n"); printf(" File name: %s\n", file->name); printf(" File size: %d\n", file->len); - printf(" Bytes read: %d\n", nbytesread); + printf(" Bytes read: %ld\n", (long)nbytesread); close(fd); return ERROR; } diff --git a/apps/examples/touchscreen/tc_main.c b/apps/examples/touchscreen/tc_main.c index 53421b302..c2c451f2f 100644 --- a/apps/examples/touchscreen/tc_main.c +++ b/apps/examples/touchscreen/tc_main.c @@ -233,8 +233,8 @@ int tc_main(int argc, char *argv[]) } else if (nbytes != sizeof(struct touch_sample_s)) { - printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", - nbytes, sizeof(struct touch_sample_s)); + printf("tc_main: Unexpected read size=%ld, expected=%d, Ignoring\n", + (long)nbytes, sizeof(struct touch_sample_s)); } /* Print the sample data on successful return */ diff --git a/apps/examples/usbserial/host.c b/apps/examples/usbserial/host.c index 366b62223..37ff9efa8 100644 --- a/apps/examples/usbserial/host.c +++ b/apps/examples/usbserial/host.c @@ -248,7 +248,7 @@ int main(int argc, char **argv, char **envp) } g_iobuffer[nbytes] = '\0'; - printf("main: Received %d bytes:\n", nbytes); + printf("main: Received %ld bytes:\n", (long)nbytes); printf(" \"%s\"\n", g_iobuffer); #else printf("main: Waiting...\n"); @@ -287,7 +287,7 @@ int main(int argc, char **argv, char **envp) close(fd); return 2; } - printf("main: %d bytes sent\n", nbytes); + printf("main: %ld bytes sent\n", (long)nbytes); #endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */ } diff --git a/apps/examples/usbserial/usbserial_main.c b/apps/examples/usbserial/usbserial_main.c index 11dda6abc..13c4bdb5c 100644 --- a/apps/examples/usbserial/usbserial_main.c +++ b/apps/examples/usbserial/usbserial_main.c @@ -352,7 +352,7 @@ int usbserial_main(int argc, char *argv[]) close(outfd); return 4; } - printf("usbserial_main: %d bytes sent\n", nbytes); + printf("usbserial_main: %ld bytes sent\n", (long)nbytes); #endif /* CONFIG_EXAMPLES_USBSERIAL_OUTONLY */ /* Test OUT (host-to-device) messages */ @@ -380,7 +380,7 @@ int usbserial_main(int argc, char *argv[]) } else { - printf("usbserial_main: Received %d bytes:\n", nbytes); + printf("usbserial_main: Received l%d bytes:\n", (long)nbytes); if (nbytes > 0) { for (j = 0; j < nbytes; j += 16) diff --git a/apps/examples/wgetjson/wgetjson_main.c b/apps/examples/wgetjson/wgetjson_main.c index 724b3b5b1..7dafbcb44 100644 --- a/apps/examples/wgetjson/wgetjson_main.c +++ b/apps/examples/wgetjson/wgetjson_main.c @@ -83,9 +83,9 @@ * Private Data ****************************************************************************/ -static char *g_json_buff = NULL; -static int g_json_bufflen = 0; -static bool g_has_json = false; +static FAR char *g_json_buff = NULL; +static int g_json_bufflen = 0; +static bool g_has_json = false; /**************************************************************************** * Private Functions @@ -113,7 +113,9 @@ static void wgetjson_postdebug_callback(FAR char **buffer, int offset, static void wgetjson_callback(FAR char **buffer, int offset, int datend, FAR int *buflen, FAR void *arg) { - int len = datend - offset,org=len; + FAR char *new_json_buff; + int len = datend - offset; + int org = len; if (len <= 0) { @@ -140,10 +142,14 @@ static void wgetjson_callback(FAR char **buffer, int offset, int datend, len = CONFIG_EXAMPLES_WGETJSON_MAXSIZE - g_json_bufflen; } - g_json_buff = realloc(g_json_buff, g_json_bufflen + len + 1); - memcpy(&g_json_buff[g_json_bufflen-1], &((*buffer)[offset]), len); - g_json_buff[g_json_bufflen + len] = 0; - g_json_bufflen += org; + new_json_buff = (FAR char *)realloc(g_json_buff, g_json_bufflen + len + 1); + if (new_json_buff) + { + g_json_buff = new_json_buff; + memcpy(&g_json_buff[g_json_bufflen-1], &((*buffer)[offset]), len); + g_json_buff[g_json_bufflen + len] = 0; + g_json_bufflen += org; + } } } -- cgit v1.2.3