From 84024e3d0160a3fceca7cc11e10a9ae99b800075 Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 14:24:07 -0700 Subject: [PATCH 1/7] Fix compiler warning type mismatch for randisk_register() and pbuffer. --- apps/examples/mount/ramdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/examples/mount/ramdisk.c b/apps/examples/mount/ramdisk.c index 83ef74e423..42724195a1 100644 --- a/apps/examples/mount/ramdisk.c +++ b/apps/examples/mount/ramdisk.c @@ -97,12 +97,12 @@ static struct fat_format_s g_fmt = FAT_FORMAT_INITIALIZER; int create_ramdisk(void) { - char *pbuffer; + uint8_t *pbuffer; int ret; /* Allocate a buffer to hold the file system image. */ - pbuffer = (char*)malloc(BUFFER_SIZE); + pbuffer = (uint8_t*)malloc(BUFFER_SIZE); if (!pbuffer) { printf("create_ramdisk: Failed to allocate ramdisk of size %d\n", From 21a61c4ff44c559992bf0d76386e6e34ce20730c Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 14:31:18 -0700 Subject: [PATCH 2/7] Fix compiler warnings about unused variables. --- nuttx/arch/arm/src/stm32/stm32_i2c.c | 1 - nuttx/arch/arm/src/stm32/stm32_otgfsdev.c | 5 +---- nuttx/arch/arm/src/stm32/stm32_rtcc.c | 5 ++--- nuttx/arch/arm/src/stm32/stm32_sdio.c | 1 - 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c index bc674c2818..e4fcb22240 100644 --- a/nuttx/arch/arm/src/stm32/stm32_i2c.c +++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c @@ -2082,7 +2082,6 @@ int up_i2creset(FAR struct i2c_dev_s * dev) unsigned clock_count; unsigned stretch_count; int ret = ERROR; - irqstate_t state; ASSERT(dev); diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c index 3873fd32ba..4263250537 100644 --- a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c +++ b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c @@ -2082,10 +2082,9 @@ static void stm32_usbreset(struct stm32_usbdev_s *priv) static inline void stm32_ep0out_testmode(FAR struct stm32_usbdev_s *priv, uint16_t index) { - uint32_t regval; uint8_t testmode; - regval = stm32_getreg(STM32_OTGFS_DCTL); + (void) stm32_getreg(STM32_OTGFS_DCTL); testmode = index >> 8; switch (testmode) @@ -4476,7 +4475,6 @@ static int stm32_ep_submit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s * static int stm32_ep_cancel(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) { FAR struct stm32_ep_s *privep = (FAR struct stm32_ep_s *)ep; - FAR struct stm32_usbdev_s *priv; irqstate_t flags; #ifdef CONFIG_DEBUG @@ -4488,7 +4486,6 @@ static int stm32_ep_cancel(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s * #endif usbtrace(TRACE_EPCANCEL, privep->epphy); - priv = privep->dev; flags = irqsave(); diff --git a/nuttx/arch/arm/src/stm32/stm32_rtcc.c b/nuttx/arch/arm/src/stm32/stm32_rtcc.c index 6ba69e2950..38e50d9d20 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rtcc.c +++ b/nuttx/arch/arm/src/stm32/stm32_rtcc.c @@ -597,7 +597,6 @@ static int rtc_interrupt(int irq, void *context) int up_rtcinitialize(void) { uint32_t regval; - int ret; /* Clocking for the PWR block must be provided. However, this is done * unconditionally in stm32f40xxx_rcc.c on power up. This done unconditionally @@ -626,7 +625,7 @@ int up_rtcinitialize(void) { /* Perform the one-time setup of the LSE clocking to the RTC */ - ret = rtc_setup(); + (void) rtc_setup(); /* Remember that the RTC is initialized */ @@ -636,7 +635,7 @@ int up_rtcinitialize(void) { /* RTC already set-up, just resume normal operation */ - ret = rtc_resume(); + (void) rtc_resume(); rtc_dumpregs("Did resume"); } diff --git a/nuttx/arch/arm/src/stm32/stm32_sdio.c b/nuttx/arch/arm/src/stm32/stm32_sdio.c index 2bbae905e3..5df240f2c2 100755 --- a/nuttx/arch/arm/src/stm32/stm32_sdio.c +++ b/nuttx/arch/arm/src/stm32/stm32_sdio.c @@ -2668,7 +2668,6 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev, { struct stm32_dev_s *priv = (struct stm32_dev_s *)dev; uint32_t dblocksize; - int ret = -EINVAL; DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0); DEBUGASSERT(stm32_dmapreflight(dev, buffer, buflen) == 0); From 77b79446624d5340d8451f1a8ecbe10e0bc1b23c Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 14:37:41 -0700 Subject: [PATCH 3/7] __dtoa() returns a pointer to internally managed storage and does not need to be freed. Remove the "if 0" dead code and unused variable 'digalloc'. --- nuttx/libc/stdio/lib_libdtoa.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/nuttx/libc/stdio/lib_libdtoa.c b/nuttx/libc/stdio/lib_libdtoa.c index 7f39701271..f0d7984c7f 100644 --- a/nuttx/libc/stdio/lib_libdtoa.c +++ b/nuttx/libc/stdio/lib_libdtoa.c @@ -150,7 +150,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, uint8_t flags, double value) { FAR char *digits; /* String returned by __dtoa */ - FAR char *digalloc; /* Copy of digits to be freed after usage */ FAR char *rve; /* Points to the end of the return value */ int expt; /* Integer value of exponent */ int numlen; /* Actual number of digits returned by cvt */ @@ -188,7 +187,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, /* Perform the conversion */ digits = __dtoa(value, 3, prec, &expt, &dsgn, &rve); - digalloc = digits; numlen = rve - digits; if (IS_NEGATE(flags)) @@ -326,15 +324,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, /* Finally, print any trailing zeroes */ zeroes(obj, prec); - - /* Is this memory supposed to be freed or not? */ - -#if 0 - if (digalloc) - { - lib_free(digalloc); - } -#endif } /**************************************************************************** From 200589f911dbcf2886c0755adb3dac62815c5f39 Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 14:42:42 -0700 Subject: [PATCH 4/7] Fix compiler warning about unsigned comparison less than zero is always false. --- nuttx/sched/mq_timedreceive.c | 2 +- nuttx/sched/mq_timedsend.c | 2 +- nuttx/sched/sem_timedwait.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nuttx/sched/mq_timedreceive.c b/nuttx/sched/mq_timedreceive.c index 774374edab..40f995e509 100644 --- a/nuttx/sched/mq_timedreceive.c +++ b/nuttx/sched/mq_timedreceive.c @@ -198,7 +198,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, void *msg, size_t msglen, return ERROR; } - if (!abstime || abstime->tv_sec < 0 || abstime->tv_nsec > 1000000000) + if (!abstime || abstime->tv_nsec > 1000000000) { set_errno(EINVAL); return ERROR; diff --git a/nuttx/sched/mq_timedsend.c b/nuttx/sched/mq_timedsend.c index 31de84fc45..f2452604cd 100644 --- a/nuttx/sched/mq_timedsend.c +++ b/nuttx/sched/mq_timedsend.c @@ -199,7 +199,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, return ERROR; } - if (!abstime || abstime->tv_sec < 0 || abstime->tv_nsec > 1000000000) + if (!abstime || abstime->tv_nsec > 1000000000) { set_errno(EINVAL); return ERROR; diff --git a/nuttx/sched/sem_timedwait.c b/nuttx/sched/sem_timedwait.c index 344b3a072c..ce37872ab5 100644 --- a/nuttx/sched/sem_timedwait.c +++ b/nuttx/sched/sem_timedwait.c @@ -223,7 +223,7 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime) * with a valid timeout. */ - if (abstime->tv_sec < 0 || abstime->tv_nsec > 1000000000) + if (abstime->tv_nsec > 1000000000) { err = EINVAL; goto errout_disabled; From 9aee8d9995ae6456d563e6edf907fb334a50dfda Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 14:44:21 -0700 Subject: [PATCH 5/7] Fix compiler warning for incorrect use of 'static void inline' instead of 'static inline void'. --- nuttx/sched/timer_settime.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nuttx/sched/timer_settime.c b/nuttx/sched/timer_settime.c index 45fd17ded4..698768e33a 100644 --- a/nuttx/sched/timer_settime.c +++ b/nuttx/sched/timer_settime.c @@ -67,8 +67,8 @@ * Private Function Prototypes ********************************************************************************/ -static void inline timer_sigqueue(FAR struct posix_timer_s *timer); -static void inline timer_restart(FAR struct posix_timer_s *timer, uint32_t itimer); +static inline void timer_sigqueue(FAR struct posix_timer_s *timer); +static inline void timer_restart(FAR struct posix_timer_s *timer, uint32_t itimer); static void timer_timeout(int argc, uint32_t itimer); /******************************************************************************** @@ -93,7 +93,7 @@ static void timer_timeout(int argc, uint32_t itimer); * ********************************************************************************/ -static void inline timer_sigqueue(FAR struct posix_timer_s *timer) +static inline void timer_sigqueue(FAR struct posix_timer_s *timer) { siginfo_t info; @@ -133,7 +133,7 @@ static void inline timer_sigqueue(FAR struct posix_timer_s *timer) * ********************************************************************************/ -static void inline timer_restart(FAR struct posix_timer_s *timer, uint32_t itimer) +static inline void timer_restart(FAR struct posix_timer_s *timer, uint32_t itimer) { /* If this is a repetitive timer, then restart the watchdog */ From b4320bfa432e03f5caab6e9a50cef2b028809c96 Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 15:11:33 -0700 Subject: [PATCH 6/7] Fix compiler warning for implict declaration of function 'vsyslog' --- nuttx/libc/stdio/lib_printf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nuttx/libc/stdio/lib_printf.c b/nuttx/libc/stdio/lib_printf.c index b035aa14f9..016e485f4c 100644 --- a/nuttx/libc/stdio/lib_printf.c +++ b/nuttx/libc/stdio/lib_printf.c @@ -42,6 +42,7 @@ ****************************************************************************/ #include +#include #include "lib_internal.h" /**************************************************************************** From f59580887d395ccd3ece5b6229e66f42937b2ee6 Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Sat, 4 Nov 2017 15:12:41 -0700 Subject: [PATCH 7/7] Fix compiler warning for unused variable 'regval' when CONFIG_DEBUG_SPI is undefined. --- nuttx/arch/arm/src/stm32/stm32_spi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.c b/nuttx/arch/arm/src/stm32/stm32_spi.c index 186cdaefab..2548c36382 100644 --- a/nuttx/arch/arm/src/stm32/stm32_spi.c +++ b/nuttx/arch/arm/src/stm32/stm32_spi.c @@ -1239,7 +1239,9 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits) static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd) { FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)dev; +#ifdef CONFIG_DEBUG_SPI uint32_t regval; +#endif uint16_t ret; DEBUGASSERT(priv && priv->spibase); @@ -1249,7 +1251,11 @@ static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd) /* Check and clear any error flags (Reading from the SR clears the error flags) */ +#ifdef CONFIG_DEBUG_SPI regval = spi_getreg(priv, STM32_SPI_SR_OFFSET); +#else + (void) spi_getreg(priv, STM32_SPI_SR_OFFSET); +#endif spivdbg("Sent: %04x Return: %04x Status: %02x\n", wd, ret, regval); return ret;