Fixes for more cppcheck complaints. Mostly cosmetic

This commit is contained in:
Gregory Nutt 2014-11-25 14:51:10 -06:00
parent 045c01c7b3
commit 8aae2cfc11
14 changed files with 44 additions and 33 deletions

View File

@ -358,8 +358,8 @@ int adc_main(int argc, char *argv[])
int nsamples = nbytes / sizeof(struct adc_msg_s); int nsamples = nbytes / sizeof(struct adc_msg_s);
if (nsamples * sizeof(struct adc_msg_s) != nbytes) if (nsamples * sizeof(struct adc_msg_s) != nbytes)
{ {
printf("adc_main: read size=%d is not a multiple of sample size=%d, Ignoring\n", printf("adc_main: read size=%ld is not a multiple of sample size=%d, Ignoring\n",
nbytes, sizeof(struct adc_msg_s)); (long)nbytes, sizeof(struct adc_msg_s));
} }
else else
{ {

View File

@ -484,8 +484,8 @@ static int bridge_net1_worker(int argc, char *argv[])
} }
else if (nsent != nrecvd) else if (nsent != nrecvd)
{ {
fprintf(stderr, "NET1 ERROR: Bad send length: %d Expected: %ld\n", fprintf(stderr, "NET1 ERROR: Bad send length: %ld Expected: %ld\n",
nsent, (long)nrecvd); (long)nsent, (long)nrecvd);
goto errout_with_sendsd; goto errout_with_sendsd;
} }
} }

View File

@ -565,9 +565,11 @@ void StartSmartConfig(void)
printf(" Enabling auto-connect policy..."); printf(" Enabling auto-connect policy...");
fflush(stdout); 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; return;
} }

View File

@ -571,7 +571,7 @@ void aio_test(void)
goto errout_with_fildes; goto errout_with_fildes;
} }
printf(" aio_cancel return %d\n"); printf(" aio_cancel return %d\n", ret);
do do
{ {
@ -614,7 +614,7 @@ void aio_test(void)
goto errout_with_fildes; goto errout_with_fildes;
} }
printf(" aio_cancel return %d\n"); printf(" aio_cancel return %d\n", ret);
do do
{ {

View File

@ -156,7 +156,7 @@ void recursive_mutex_test(void)
{ {
printf("recursive_mutex_test: Waiting for thread %d\n", i+1); printf("recursive_mutex_test: Waiting for thread %d\n", i+1);
#ifdef SDCC #ifdef SDCC
pthread_join(thread[i], &result1); pthread_join(thread[i], &result[i]);
#else #else
pthread_join(thread[i], NULL); pthread_join(thread[i], NULL);
#endif #endif

View File

@ -242,7 +242,8 @@ void *poll_listener(pthread_addr_t pvarg)
} }
buffer[nbytes] = '\0'; 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 */ /* Suppress error report if no read data on the next time through */

View File

@ -199,7 +199,8 @@ int poll_main(int argc, char *argv[])
goto errout; 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); fflush(stdout);
/* Wait awhile. This delay should be long enough that the /* Wait awhile. This delay should be long enough that the

View File

@ -307,7 +307,8 @@ static void checkfile(const char *path, struct node_s *node)
} }
else if (nbytesread != node->size) 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++; g_nerrors++;
} }
else if (memcmp(g_scratchbuffer, node->u.filecontent, node->size) != 0) else if (memcmp(g_scratchbuffer, node->u.filecontent, node->size) != 0)

View File

@ -317,7 +317,7 @@ int slcd_main(int argc, char *argv[])
/* Set the brightness to the mid value */ /* Set the brightness to the mid value */
brightness = ((unsigned long)priv->attr.maxbrightness + 1) >> 1; 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); ret = ioctl(fd, SLCDIOC_SETBRIGHTNESS, brightness);
if (ret < 0) if (ret < 0)

View File

@ -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("ERROR: Read past the end of file\n");
printf(" File name: %s\n", file->name); printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len); printf(" File size: %d\n", file->len);
printf(" Bytes read: %d\n", nbytesread); printf(" Bytes read: %ld\n", (long)nbytesread);
close(fd); close(fd);
return ERROR; return ERROR;
} }

View File

@ -233,8 +233,8 @@ int tc_main(int argc, char *argv[])
} }
else if (nbytes != sizeof(struct touch_sample_s)) else if (nbytes != sizeof(struct touch_sample_s))
{ {
printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", printf("tc_main: Unexpected read size=%ld, expected=%d, Ignoring\n",
nbytes, sizeof(struct touch_sample_s)); (long)nbytes, sizeof(struct touch_sample_s));
} }
/* Print the sample data on successful return */ /* Print the sample data on successful return */

View File

@ -248,7 +248,7 @@ int main(int argc, char **argv, char **envp)
} }
g_iobuffer[nbytes] = '\0'; g_iobuffer[nbytes] = '\0';
printf("main: Received %d bytes:\n", nbytes); printf("main: Received %ld bytes:\n", (long)nbytes);
printf(" \"%s\"\n", g_iobuffer); printf(" \"%s\"\n", g_iobuffer);
#else #else
printf("main: Waiting...\n"); printf("main: Waiting...\n");
@ -287,7 +287,7 @@ int main(int argc, char **argv, char **envp)
close(fd); close(fd);
return 2; return 2;
} }
printf("main: %d bytes sent\n", nbytes); printf("main: %ld bytes sent\n", (long)nbytes);
#endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */ #endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
} }

View File

@ -352,7 +352,7 @@ int usbserial_main(int argc, char *argv[])
close(outfd); close(outfd);
return 4; return 4;
} }
printf("usbserial_main: %d bytes sent\n", nbytes); printf("usbserial_main: %ld bytes sent\n", (long)nbytes);
#endif /* CONFIG_EXAMPLES_USBSERIAL_OUTONLY */ #endif /* CONFIG_EXAMPLES_USBSERIAL_OUTONLY */
/* Test OUT (host-to-device) messages */ /* Test OUT (host-to-device) messages */
@ -380,7 +380,7 @@ int usbserial_main(int argc, char *argv[])
} }
else else
{ {
printf("usbserial_main: Received %d bytes:\n", nbytes); printf("usbserial_main: Received l%d bytes:\n", (long)nbytes);
if (nbytes > 0) if (nbytes > 0)
{ {
for (j = 0; j < nbytes; j += 16) for (j = 0; j < nbytes; j += 16)

View File

@ -83,7 +83,7 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static char *g_json_buff = NULL; static FAR char *g_json_buff = NULL;
static int g_json_bufflen = 0; static int g_json_bufflen = 0;
static bool g_has_json = false; static bool g_has_json = false;
@ -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, static void wgetjson_callback(FAR char **buffer, int offset, int datend,
FAR int *buflen, FAR void *arg) 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) if (len <= 0)
{ {
@ -140,12 +142,16 @@ static void wgetjson_callback(FAR char **buffer, int offset, int datend,
len = CONFIG_EXAMPLES_WGETJSON_MAXSIZE - g_json_bufflen; len = CONFIG_EXAMPLES_WGETJSON_MAXSIZE - g_json_bufflen;
} }
g_json_buff = realloc(g_json_buff, g_json_bufflen + len + 1); 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); memcpy(&g_json_buff[g_json_bufflen-1], &((*buffer)[offset]), len);
g_json_buff[g_json_bufflen + len] = 0; g_json_buff[g_json_bufflen + len] = 0;
g_json_bufflen += org; g_json_bufflen += org;
} }
} }
}
/**************************************************************************** /****************************************************************************
* Name: wgetjson_json_release * Name: wgetjson_json_release