From 2994448d8556bd9891d59e3e664b1c1a63c3ebc5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 25 Nov 2014 13:15:09 -0600 Subject: [PATCH] More fixes to problems noted by cppcheck. Some are kind of risky; some are real bugs. --- arch/arm/src/c5471/c5471_serial.c | 24 +++++----- arch/arm/src/calypso/calypso_serial.c | 26 +++++----- arch/arm/src/efm32/efm32_dma.c | 2 +- arch/arm/src/str71x/str71x_serial.c | 2 +- arch/arm/src/tiva/tiva_ssi.c | 3 +- arch/avr/src/avr/up_spi.c | 4 ++ arch/z80/src/ez80/ez80_spi.c | 3 +- arch/z80/src/ez80/ez80_timerisr.c | 13 ++--- arch/z80/src/z180/z180_scc.c | 2 - arch/z80/src/z180/z180_timerisr.c | 8 ++-- arch/z80/src/z8/z8_lowuart.c | 3 ++ audio/pcm_decode.c | 34 ++++++------- configs/ea3131/src/up_mem.c | 3 +- configs/ea3152/src/up_mem.c | 3 +- configs/mikroe-stm32f4/src/up_clockconfig.c | 2 +- configs/mikroe-stm32f4/src/up_nsh.c | 4 ++ configs/mikroe-stm32f4/src/up_touchscreen.c | 1 - configs/mx1ads/src/up_boot.c | 4 +- configs/olimex-lpc-h3131/src/lpc31_mem.c | 3 +- configs/olimex-stm32-h405/src/stm32_nsh.c | 6 ++- configs/open1788/src/lpc17_sdraminitialize.c | 9 +--- configs/shenzhou/src/up_ili93xx.c | 4 +- configs/stm32f4discovery/src/stm32_usb.c | 3 ++ configs/vsn/src/sif.c | 7 +-- crypto/crypto.c | 24 +++++++--- drivers/analog/ads1255.c | 14 +++--- drivers/audio/wm8904.c | 2 +- drivers/input/mxt.c | 2 + drivers/lcd/mio283qt9a.c | 8 +++- drivers/mtd/rammtd.c | 2 +- drivers/mtd/smart.c | 6 +-- drivers/mtd/sst25.c | 2 +- drivers/net/dm90x0.c | 6 +-- drivers/net/e1000.c | 50 ++++++++++---------- drivers/power/max1704x.c | 1 - drivers/power/pm_activity.c | 2 +- drivers/usbdev/usbmsc_scsi.c | 4 +- 37 files changed, 156 insertions(+), 140 deletions(-) diff --git a/arch/arm/src/c5471/c5471_serial.c b/arch/arm/src/c5471/c5471_serial.c index 81cb084679..4aa51ff6ad 100644 --- a/arch/arm/src/c5471/c5471_serial.c +++ b/arch/arm/src/c5471/c5471_serial.c @@ -84,20 +84,20 @@ struct uart_regs_s struct up_dev_s { - unsigned int uartbase; /* Base address of UART registers */ - unsigned int baud_base; /* Base baud for conversions */ - unsigned int baud; /* Configured baud */ - uint8_t xmit_fifo_size; /* Size of transmit FIFO */ - uint8_t irq; /* IRQ associated with this UART */ - uint8_t parity; /* 0=none, 1=odd, 2=even */ - uint8_t bits; /* Number of bits (7 or 8) */ + unsigned int uartbase; /* Base address of UART registers */ + unsigned int baud_base; /* Base baud for conversions */ + unsigned int baud; /* Configured baud */ + uint8_t xmit_fifo_size; /* Size of transmit FIFO */ + uint8_t irq; /* IRQ associated with this UART */ + uint8_t parity; /* 0=none, 1=odd, 2=even */ + uint8_t bits; /* Number of bits (7 or 8) */ #ifdef CONFIG_UART_HWFLOWCONTROL - bool flowcontrol; /* true: Hardware flow control - * is enabled. */ + bool flowcontrol; /* true: Hardware flow control + * is enabled. */ #endif - bool stopbits2; /* true: Configure with 2 - * stop bits instead of 1 */ - struct uart_regs_s regs; /* Shadow copy of readonly regs */ + bool stopbits2; /* true: Configure with 2 + * stop bits instead of 1 */ + struct uart_regs_s regs; /* Shadow copy of readonly regs */ }; /**************************************************************************** diff --git a/arch/arm/src/calypso/calypso_serial.c b/arch/arm/src/calypso/calypso_serial.c index 0fceb344da..c19ac2858c 100644 --- a/arch/arm/src/calypso/calypso_serial.c +++ b/arch/arm/src/calypso/calypso_serial.c @@ -94,23 +94,23 @@ struct uart_regs_s struct up_dev_s { - unsigned int uartbase; /* Base address of UART registers */ - unsigned int baud_base; /* Base baud for conversions */ - unsigned int baud; /* Configured baud */ - uint8_t xmit_fifo_size; /* Size of transmit FIFO */ - uint8_t irq; /* IRQ associated with this UART */ - uint8_t parity; /* 0=none, 1=odd, 2=even */ - uint8_t bits; /* Number of bits (7 or 8) */ + unsigned int uartbase; /* Base address of UART registers */ + unsigned int baud_base; /* Base baud for conversions */ + unsigned int baud; /* Configured baud */ + uint8_t xmit_fifo_size; /* Size of transmit FIFO */ + uint8_t irq; /* IRQ associated with this UART */ + uint8_t parity; /* 0=none, 1=odd, 2=even */ + uint8_t bits; /* Number of bits (7 or 8) */ #ifdef CONFIG_UART_HWFLOWCONTROL - bool flowcontrol; /* true: Hardware flow control - * is enabled. */ + bool flowcontrol; /* true: Hardware flow control + * is enabled. */ #endif - bool stopbits2; /* true: Configure with 2 - * stop bits instead of 1 */ - struct uart_regs_s regs; /* Shadow copy of readonly regs */ + bool stopbits2; /* true: Configure with 2 + * stop bits instead of 1 */ + struct uart_regs_s regs; /* Shadow copy of readonly regs */ #ifdef CONFIG_SERCOMM_CONSOLE - bool sercomm; /* Call sercomm in interrupt if true */ + bool sercomm; /* Call sercomm in interrupt if true */ #endif }; diff --git a/arch/arm/src/efm32/efm32_dma.c b/arch/arm/src/efm32/efm32_dma.c index f27929c0e3..8f32168fb7 100644 --- a/arch/arm/src/efm32/efm32_dma.c +++ b/arch/arm/src/efm32/efm32_dma.c @@ -717,7 +717,7 @@ void efm32_dmastop(DMA_HANDLE handle) uint32_t regval; uint32_t bit; - DEBUGASSERT(dmach && dmach); + DEBUGASSERT(dmach); bit = 1 << dmach->chan; /* Disable the channel */ diff --git a/arch/arm/src/str71x/str71x_serial.c b/arch/arm/src/str71x/str71x_serial.c index bfa11b559f..27dfd69764 100644 --- a/arch/arm/src/str71x/str71x_serial.c +++ b/arch/arm/src/str71x/str71x_serial.c @@ -631,8 +631,8 @@ static int up_attach(struct uart_dev_s *dev) /* Set the uart interrupt priority (the default value is one) */ up_prioritize_irq(priv->irq, CONFIG_UART_PRI); - } #endif + } return ret; } diff --git a/arch/arm/src/tiva/tiva_ssi.c b/arch/arm/src/tiva/tiva_ssi.c index 8f1c0c79de..dfe1d737a5 100644 --- a/arch/arm/src/tiva/tiva_ssi.c +++ b/arch/arm/src/tiva/tiva_ssi.c @@ -951,7 +951,6 @@ static int ssi_interrupt(int irq, void *context) { struct tiva_ssidev_s *priv = ssi_mapirq(irq); uint32_t regval; - int ntxd; DEBUGASSERT(priv != NULL); @@ -975,7 +974,7 @@ static int ssi_interrupt(int irq, void *context) /* Handle outgoing Tx FIFO transfers */ - ntxd = ssi_performtx(priv); + (void)ssi_performtx(priv); /* Handle incoming Rx FIFO transfers */ diff --git a/arch/avr/src/avr/up_spi.c b/arch/avr/src/avr/up_spi.c index 78a4fa9ba5..5bad79bda7 100644 --- a/arch/avr/src/avr/up_spi.c +++ b/arch/avr/src/avr/up_spi.c @@ -267,6 +267,8 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency) actual = BOARD_CPU_CLOCK / 128; } +#warning REVIST: spcr/spsr are never used + /* Save the frequency setting */ #ifndef CONFIG_SPI_OWNBUS @@ -531,6 +533,8 @@ FAR struct spi_dev_s *up_spiinitialize(int port) #ifndef CONFIG_SPI_OWNBUS sem_init(&priv->exclsem, 0, 1); #endif + + irqrestore(flags); return &priv->spidev; } #endif /* CONFIG_AVR_SPI */ diff --git a/arch/z80/src/ez80/ez80_spi.c b/arch/z80/src/ez80/ez80_spi.c index 8a6eab6630..5757f4ed65 100644 --- a/arch/z80/src/ez80/ez80_spi.c +++ b/arch/z80/src/ez80/ez80_spi.c @@ -359,13 +359,12 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t buflen) { FAR const uint8_t *ptr = (FAR const uint8_t*)buffer; - uint8_t response; /* Loop while there are bytes remaining to be sent */ while (buflen-- > 0) { - response = spi_transfer(*ptr++); + (void)spi_transfer(*ptr++); } } diff --git a/arch/z80/src/ez80/ez80_timerisr.c b/arch/z80/src/ez80/ez80_timerisr.c index 4fbc49c0db..3980d98f84 100644 --- a/arch/z80/src/ez80/ez80_timerisr.c +++ b/arch/z80/src/ez80/ez80_timerisr.c @@ -76,16 +76,14 @@ int up_timerisr(int irq, chipreg_t *regs) { - volatile uint8_t reg; - - /* Read the appropropriate timer0 registr to clear the interrupt */ + /* Read the appropriate timer0 register to clear the interrupt */ #ifdef _EZ80F91 - reg = inp(EZ80_TMR0_IIR); + (void)inp(EZ80_TMR0_IIR); #else /* _EZ80190, _EZ80L92, _EZ80F92, _EZ80F93 */ - reg = inp(EZ80_TMR0_CTL); + (void)inp(EZ80_TMR0_CTL); #endif /* Process timer interrupt */ @@ -113,7 +111,6 @@ int up_timerisr(int irq, chipreg_t *regs) void up_timer_initialize(void) { uint16_t reload; - uint8_t reg; /* Disable the timer */ @@ -149,9 +146,9 @@ void up_timer_initialize(void) /* Clear any pending timer interrupts */ #if defined(_EZ80F91) - reg = inp(EZ80_TMR0_IIR); + (void)inp(EZ80_TMR0_IIR); #elif defined(_EZ80L92) || defined(_EZ80F92) ||defined(_EZ80F93) - reg = inp(EZ80_TMR0_CTL); + (void)inp(EZ80_TMR0_CTL); #endif /* Configure and enable the timer */ diff --git a/arch/z80/src/z180/z180_scc.c b/arch/z80/src/z180/z180_scc.c index 8655d907ca..b8f1565037 100644 --- a/arch/z80/src/z180/z180_scc.c +++ b/arch/z80/src/z180/z180_scc.c @@ -575,8 +575,6 @@ static bool z180_txempty(struct uart_dev_s *dev) void up_serialinit(void) { - uint8_t regval; - /* Make sure that all UART interrupts are disabled */ #warning "Missing logic" diff --git a/arch/z80/src/z180/z180_timerisr.c b/arch/z80/src/z180/z180_timerisr.c index 35d21c5a0a..253fd43270 100644 --- a/arch/z80/src/z180/z180_timerisr.c +++ b/arch/z80/src/z180/z180_timerisr.c @@ -94,16 +94,14 @@ int up_timerisr(int irq, chipreg_t *regs) { - volatile uint8_t regval; - /* "When TMDR0 decrements to 0, TIF0 is set to 1. This generates an interrupt * request if enabled by TIE0 = 1. TIF0 is reset to 0 when TCR is read and * the higher or lower byte of TMDR0 is read." */ - regval = inp(Z180_PRT_TCR); - regval = inp(Z180_PRT0_DRL); - regval = inp(Z180_PRT0_DRH); + (void)inp(Z180_PRT_TCR); + (void)inp(Z180_PRT0_DRL); + (void)inp(Z180_PRT0_DRH); /* Process timer interrupt */ diff --git a/arch/z80/src/z8/z8_lowuart.c b/arch/z80/src/z8/z8_lowuart.c index ad4acb6e96..580b0e7848 100644 --- a/arch/z80/src/z8/z8_lowuart.c +++ b/arch/z80/src/z8/z8_lowuart.c @@ -75,9 +75,12 @@ extern uint32_t get_freq(void); void up_lowserialinit(void) { +#if defined(CONFIG_UART0_SERIAL_CONSOLE) || \ + (defined(EZ8_UART1) && defined(CONFIG_UART1_SERIAL_CONSOLE)) uint32_t freq = get_freq(); uint16_t brg; uint8_t val; +#endif #ifdef CONFIG_UART0_SERIAL_CONSOLE /* Set the baudrate */ diff --git a/audio/pcm_decode.c b/audio/pcm_decode.c index 14e228a6d9..b8808a2cb7 100644 --- a/audio/pcm_decode.c +++ b/audio/pcm_decode.c @@ -442,8 +442,8 @@ static void pcm_subsample_configure(FAR struct pcm_decode_s *priv, if (priv->subsample == AUDIO_SUBSAMPLE_NONE) { - /* Ignore request to stop fast forwarding if we are already - * fast forwarding. + /* Ignore request to stop fast forwarding if we are already playing + * normally. */ if (subsample != AUDIO_SUBSAMPLE_NONE) @@ -460,24 +460,11 @@ static void pcm_subsample_configure(FAR struct pcm_decode_s *priv, } } - /* 2. Were already fast forwarding and we have been asked to change the - * sub-sampling rate. - */ - - else if (subsample != AUDIO_SUBSAMPLE_NONE) - { - /* Just save the current subsample setting. It will take effect - * on the next audio buffer that we receive. - */ - - priv->subsample = subsample; - } - - /* 3. We were already fast forwarding and we have been asked to return to + /* 2. We were already fast forwarding and we have been asked to return to * normal play. */ - else if (subsample != AUDIO_SUBSAMPLE_NONE) + else if (subsample == AUDIO_SUBSAMPLE_NONE) { audvdbg("Stop sub-sampling\n"); @@ -489,6 +476,19 @@ static void pcm_subsample_configure(FAR struct pcm_decode_s *priv, priv->skip = 0; priv->subsample = AUDIO_SUBSAMPLE_NONE; } + + /* 3. Were already fast forwarding and we have been asked to change the + * sub-sampling rate. + */ + + else if (priv->subsample != subsample) + { + /* Just save the new subsample setting. It will take effect on the + * next audio buffer that we receive. + */ + + priv->subsample = subsample; + } } #endif diff --git a/configs/ea3131/src/up_mem.c b/configs/ea3131/src/up_mem.c index db38c2ce3e..1426fe91c5 100644 --- a/configs/ea3131/src/up_mem.c +++ b/configs/ea3131/src/up_mem.c @@ -157,7 +157,6 @@ static void lpc31_sdraminitialize(void) { - uint32_t tmp; uint32_t regval; /* These run-time calculations can be reduced dramatically if hclk is @@ -266,7 +265,7 @@ static void lpc31_sdraminitialize(void) * 16bit mode */ - tmp = getreg32(LPC31_EXTSDRAM0_VSECTION | (0x23 << 13)); + (void)getreg32(LPC31_EXTSDRAM0_VSECTION | (0x23 << 13)); putreg32((MPMC_DYNCONFIG0_MDSDRAM|MPMC_DYNCONFIG_HP16_32MX16), LPC31_MPMC_DYNCONFIG0); diff --git a/configs/ea3152/src/up_mem.c b/configs/ea3152/src/up_mem.c index 3bd826ec39..234a4a9fc7 100644 --- a/configs/ea3152/src/up_mem.c +++ b/configs/ea3152/src/up_mem.c @@ -157,7 +157,6 @@ static void lpc31_sdraminitialize(void) { - uint32_t tmp; uint32_t regval; /* These run-time calculations can be reduced dramatically if hclk is @@ -266,7 +265,7 @@ static void lpc31_sdraminitialize(void) * 16bit mode */ - tmp = getreg32(LPC31_EXTSDRAM0_VSECTION | (0x23 << 13)); + (void)getreg32(LPC31_EXTSDRAM0_VSECTION | (0x23 << 13)); putreg32((MPMC_DYNCONFIG0_MDSDRAM|MPMC_DYNCONFIG_HP16_32MX16), LPC31_MPMC_DYNCONFIG0); diff --git a/configs/mikroe-stm32f4/src/up_clockconfig.c b/configs/mikroe-stm32f4/src/up_clockconfig.c index 8950147eef..eb3f819991 100644 --- a/configs/mikroe-stm32f4/src/up_clockconfig.c +++ b/configs/mikroe-stm32f4/src/up_clockconfig.c @@ -146,5 +146,5 @@ void stm32_board_clockconfig(void) while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_MASK) != RCC_CFGR_SWS_PLL) ; -#endif } +#endif diff --git a/configs/mikroe-stm32f4/src/up_nsh.c b/configs/mikroe-stm32f4/src/up_nsh.c index b68101c0a4..0963ccf69a 100644 --- a/configs/mikroe-stm32f4/src/up_nsh.c +++ b/configs/mikroe-stm32f4/src/up_nsh.c @@ -169,7 +169,11 @@ int nsh_archinitialize(void) FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; #endif +#if defined(NSH_HAVEMMCSD) || defined(HAVE_USBHOST) || \ + defined(HAVE_USBMONITOR) || defined(CONFIG_LCD_MIO283QT2) || \ + defined(CONFIG_LCD_MIO283QT9A) int ret; +#endif /* Configure SPI-based devices */ diff --git a/configs/mikroe-stm32f4/src/up_touchscreen.c b/configs/mikroe-stm32f4/src/up_touchscreen.c index f8b7f5e4dc..30b65e6bb5 100644 --- a/configs/mikroe-stm32f4/src/up_touchscreen.c +++ b/configs/mikroe-stm32f4/src/up_touchscreen.c @@ -435,7 +435,6 @@ static void tc_adc_init(void) regval = tc_adc_getreg(STM32_ADC_SQR3_OFFSET) & ADC_SQR3_RESERVED; regval |= LCD_YD_CHANNEL; tc_adc_putreg(STM32_ADC_SQR3_OFFSET, regval); - regval = tc_adc_getreg(STM32_ADC_SQR3_OFFSET); /* Set the number of conversions = 1 */ diff --git a/configs/mx1ads/src/up_boot.c b/configs/mx1ads/src/up_boot.c index 6d7576d0c4..82991c1fe2 100644 --- a/configs/mx1ads/src/up_boot.c +++ b/configs/mx1ads/src/up_boot.c @@ -101,7 +101,7 @@ void imx_boardinitialize(void) imxgpio_configprimary(GPIOA, 21); imxgpio_configprimary(GPIOA, 22); - regval = getreg32(IMX_CS4_VSECTION + 0x0c); - regval = getreg32(IMX_CS4_VSECTION + 0x0c); + (void)getreg32(IMX_CS4_VSECTION + 0x0c); + (void)getreg32(IMX_CS4_VSECTION + 0x0c); #endif } diff --git a/configs/olimex-lpc-h3131/src/lpc31_mem.c b/configs/olimex-lpc-h3131/src/lpc31_mem.c index 389a62f4e6..a99e6baf41 100644 --- a/configs/olimex-lpc-h3131/src/lpc31_mem.c +++ b/configs/olimex-lpc-h3131/src/lpc31_mem.c @@ -137,7 +137,6 @@ static uint32_t lpc31_ns2clk(uint32_t ns, uint32_t hclk2) static inline void lpc31_sdraminitialize(void) { - uint32_t tmp; uint32_t regval; /* These run-time calculations can be reduced dramatically if hclk is @@ -254,7 +253,7 @@ static inline void lpc31_sdraminitialize(void) * 16bit mode */ - tmp = getreg32(LPC31_EXTSDRAM0_VSECTION | (0x23 << 12)); + (void)getreg32(LPC31_EXTSDRAM0_VSECTION | (0x23 << 12)); /* Select normal operating mode */ diff --git a/configs/olimex-stm32-h405/src/stm32_nsh.c b/configs/olimex-stm32-h405/src/stm32_nsh.c index 73f7923f15..d5a65abd4c 100644 --- a/configs/olimex-stm32-h405/src/stm32_nsh.c +++ b/configs/olimex-stm32-h405/src/stm32_nsh.c @@ -59,6 +59,10 @@ * Pre-Processor Definitions ****************************************************************************/ +#if !defined(CONFIG_STM32_CAN1) && !defined(CONFIG_STM32_CAN2) +# undef CONFIG_CAN +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -84,7 +88,7 @@ int nsh_archinitialize(void) int ret; #endif -#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)) +#ifdef CONFIG_CAN /* Configure on-board CAN if CAN support has been selected. */ ret = stm32_can_initialize(); diff --git a/configs/open1788/src/lpc17_sdraminitialize.c b/configs/open1788/src/lpc17_sdraminitialize.c index be4f275f4b..5fa7bb9103 100644 --- a/configs/open1788/src/lpc17_sdraminitialize.c +++ b/configs/open1788/src/lpc17_sdraminitialize.c @@ -109,11 +109,6 @@ void open1788_sdram_initialize(void) { uint32_t regval; -#ifdef CONFIG_LPC17_SDRAM_16BIT - volatile uint16_t dummy; -#else - volatile uint32_t dummy; -#endif int i; /* Reconfigure delays: @@ -211,9 +206,9 @@ void open1788_sdram_initialize(void) LPC17_EMC_DYNAMICCONTROL); #ifdef CONFIG_LPC17_SDRAM_16BIT - dummy = getreg16(SDRAM_BASE | (0x33 << 12)); /* 8 burst, 3 CAS latency */ + (void)getreg16(SDRAM_BASE | (0x33 << 12)); /* 8 burst, 3 CAS latency */ #elif defined CONFIG_LPC17_SDRAM_32BIT - dummy = getreg32(SDRAM_BASE | (0x32 << 13)); /* 4 burst, 3 CAS latency */ + (void)getreg32(SDRAM_BASE | (0x32 << 13)); /* 4 burst, 3 CAS latency */ #endif /* Issue NORMAL command */ diff --git a/configs/shenzhou/src/up_ili93xx.c b/configs/shenzhou/src/up_ili93xx.c index cfe27cd95b..84395b6b7e 100644 --- a/configs/shenzhou/src/up_ili93xx.c +++ b/configs/shenzhou/src/up_ili93xx.c @@ -1197,14 +1197,14 @@ static int stm32_setpower(struct lcd_dev_s *dev, int power) else #endif #ifndef CONFIG_STM32_ILI9320_DISABLE - if (priv->type == LCD_TYPE_ILI9300) + if (priv->type == LCD_TYPE_ILI9320) { stm32_writereg(priv, LCD_REG_7, 0x0173); } else #endif #ifndef CONFIG_STM32_ILI9321_DISABLE - if (priv->type == LCD_TYPE_ILI9300) + if (priv->type == LCD_TYPE_ILI9321) { stm32_writereg(priv, LCD_REG_7, 0x0173); } diff --git a/configs/stm32f4discovery/src/stm32_usb.c b/configs/stm32f4discovery/src/stm32_usb.c index b1b24511cd..7afb60d453 100644 --- a/configs/stm32f4discovery/src/stm32_usb.c +++ b/configs/stm32f4discovery/src/stm32_usb.c @@ -170,7 +170,10 @@ void stm32_usbinitialize(void) int stm32_usbhost_initialize(void) { int pid; +#if defined(CONFIG_USBHOST_MSC) || defined(CONFIG_USBHOST_HIDKBD) || \ + defined(CONFIG_USBHOST_HIDMOUSE) int ret; +#endif /* First, register all of the class drivers needed to support the drivers * that we care about: diff --git a/configs/vsn/src/sif.c b/configs/vsn/src/sif.c index d9e859cc78..4488357af0 100644 --- a/configs/vsn/src/sif.c +++ b/configs/vsn/src/sif.c @@ -577,7 +577,8 @@ int sif_main(int argc, char *argv[]) } else if (status != 0) { if (stpage != 0xFFFF) { - printf("Free Range:\t%d\t-\t%d\n", stpage, page-2); + printf("Free Range:\t%lu\t-\t%lu\n", + (unsigned long)stpage, (unsigned long)(page-2)); stpage = 0xFFFF; } } @@ -594,8 +595,8 @@ int sif_main(int argc, char *argv[]) size_t page = atoi(argv[2]); size_t addr = page * up_progmem_pagesize(page); - printf("Write result: %d (writing to address %xh)\n", - up_progmem_write(addr, "Test", 4), addr); + printf("Write result: %d (writing to address %lxh)\n", + up_progmem_write(addr, "Test", 4), (unsigned long)addr); return 0; } else if (!strcmp(argv[1], "i2c") && argc == 3) { diff --git a/crypto/crypto.c b/crypto/crypto.c index b1978343b7..b0c664097f 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -66,21 +66,31 @@ void up_cryptoinitialize(void) { - int res = OK; +#if defined(CONFIG_CRYPTO_AES) || defined(CONFIG_CRYPTO_ALGTEST) + int res; -#if defined(CONFIG_CRYPTO_AES) +#ifdef CONFIG_CRYPTO_AES res = up_aesinitialize(); if (res) - return res; + { + return res; + } #endif -#if defined(CONFIG_CRYPTO_ALGTEST) +#if CONFIG_CRYPTO_ALGTEST res = crypto_test(); if (res) - cryptlldbg("crypto test failed\n"); + { + cryptlldbg("crypto test failed\n"); + } else - cryptllvdbg("crypto test OK\n"); + { + cryptllvdbg("crypto test OK\n"); + } #endif return res; -} \ No newline at end of file +#else + return OK; +#endif +} diff --git a/drivers/analog/ads1255.c b/drivers/analog/ads1255.c index 0fd771001d..2d8d59774e 100644 --- a/drivers/analog/ads1255.c +++ b/drivers/analog/ads1255.c @@ -168,23 +168,25 @@ static uint8_t getspsreg(uint16_t sps) { static const unsigned short sps_tab[]= { - 3,7,12,20,27,40,55,80,300,750,1500,3000,5000,10000,20000,65535, + 3, 7, 12, 20, 27, 40, 55, 80, + 300, 750, 1500, 3000, 5000, 10000, 20000, 65535, }; static const unsigned char sps_reg[]= { - 0x03,0x13,0x23,0x33,0x43,0x53,0x63,0x72,0x82,0x92,0xa1,0xb0,0xc0,0xd0,0xe0,0xf0, + 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x72, + 0x82, 0x92, 0xa1, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, }; int i; - for (i=0; i<16; i++) + for (i = 0; i < 16; i++) { - if (spscurbyte, apb->nbytes, apb->flags); diff --git a/drivers/input/mxt.c b/drivers/input/mxt.c index 318d1c0b55..ca28f936e0 100644 --- a/drivers/input/mxt.c +++ b/drivers/input/mxt.c @@ -750,6 +750,8 @@ static void mxt_button_event(FAR struct mxt_dev_s *priv, button = (msg->body[0] & mask) == 0; /* Now what? */ + + UNUSED(button); } } } diff --git a/drivers/lcd/mio283qt9a.c b/drivers/lcd/mio283qt9a.c index d245b07a49..8ec36a3abd 100644 --- a/drivers/lcd/mio283qt9a.c +++ b/drivers/lcd/mio283qt9a.c @@ -719,11 +719,13 @@ static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contra static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) { FAR struct mio283qt9a_lcd_s *lcd = priv->lcd; -#ifndef CONFIG_LCD_NOGETRUN +#if !defined(CONFIG_LCD_NOGETRUN) || defined(CONFIG_DEBUG_LCD) uint16_t id_a; uint16_t id_b; uint16_t id_c; uint16_t id_d; +#endif +#ifdef CONFIG_DEBUG_LCD uint16_t id_e; #endif int ret; @@ -741,6 +743,8 @@ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) id_d = lcd->read(lcd); lcdvdbg("LCD ID: %04x %04x %04x %04x\n", id_a, id_b, id_c, id_d); + UNUSED(id_a); + UNUSED(id_b); /* Check if the ID is for the ILI9341 */ @@ -773,6 +777,7 @@ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) mio283qt9a_putreg(lcd, 0x11, 0); /* Sleep out mode */ up_mdelay(25); +#ifdef CONFIG_DEBUG_LCD /* Read back some info from the panel */ id_a = mio283qt9a_readreg(lcd, 0x04); /* Read display information */ @@ -811,6 +816,7 @@ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) id_a = mio283qt9a_readreg(lcd, 0x0f); /* read self diag */ id_b = lcd->read(lcd); lcdvdbg("Self diag %02x, %02x\n", id_a, id_b); +#endif ret = OK; } #ifndef CONFIG_LCD_NOGETRUN diff --git a/drivers/mtd/rammtd.c b/drivers/mtd/rammtd.c index e84d94b61e..06497e13f8 100644 --- a/drivers/mtd/rammtd.c +++ b/drivers/mtd/rammtd.c @@ -453,7 +453,7 @@ FAR struct mtd_dev_s *rammtd_initialize(FAR uint8_t *start, size_t size) /* Force the size to be an even number of the erase block size */ nblocks = size / CONFIG_RAMMTD_ERASESIZE; - if (nblocks <= 0) + if (nblocks < 1) { fdbg("Need to provide at least one full erase block\n"); return NULL; diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c index cab0ecdf33..ccb11501e8 100644 --- a/drivers/mtd/smart.c +++ b/drivers/mtd/smart.c @@ -836,11 +836,11 @@ static int smart_scan(struct smart_struct_s *dev) rootdirdev->dev = dev; rootdirdev->rootdirnum = x; - ret = register_blockdriver(dev->rwbuffer, &g_bops, 0, rootdirdev); + (void)register_blockdriver(dev->rwbuffer, &g_bops, 0, rootdirdev); /* Inode private data is a reference to the SMART device structure */ - ret = register_blockdriver(devname, &g_bops, 0, rootdirdev); + (void)register_blockdriver(devname, &g_bops, 0, rootdirdev); } #endif } @@ -1359,7 +1359,7 @@ static int smart_garbagecollect(struct smart_struct_s *dev) /* Write the data to the new physical sector location */ - ret = MTD_BWRITE(dev->mtd, newsector * dev->mtdBlksPerSector, + (void)MTD_BWRITE(dev->mtd, newsector * dev->mtdBlksPerSector, dev->mtdBlksPerSector, (uint8_t *) dev->rwbuffer); /* Commit the sector */ diff --git a/drivers/mtd/sst25.c b/drivers/mtd/sst25.c index edd8b7b303..324cbf363f 100644 --- a/drivers/mtd/sst25.c +++ b/drivers/mtd/sst25.c @@ -714,7 +714,7 @@ static void sst25_wordwrite(struct sst25_dev_s *priv, FAR const uint8_t *buffer, * we are finished. */ - if (nwords <= 0) + if (nwords < 1) { return; } diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index 96ed6a0699..5c68062c3f 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -891,8 +891,6 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) { union rx_desc_u rx; bool bchecksumready; - uint8_t mdrah; - uint8_t mdral; uint8_t rxbyte; nvdbg("Packet received\n"); @@ -901,8 +899,8 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) { /* Store the value of memory data read address register */ - mdrah = getreg(DM9X_MDRAH); - mdral = getreg(DM9X_MDRAL); + (void)getreg(DM9X_MDRAH); + (void)getreg(DM9X_MDRAL); getreg(DM9X_MRCMDX); /* Dummy read */ rxbyte = (uint8_t)DM9X_DATA; /* Get the most up-to-date data */ diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 17c36c133a..474daf8f36 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -270,7 +270,7 @@ void e1000_turn_off(struct e1000_dev *dev) void e1000_init(struct e1000_dev *dev) { - uint32_t rxd_phy; + uint32_t rxd_phys; uint32_t txd_phys; uint32_t kmem_phys; uint32_t rx_control; @@ -570,35 +570,33 @@ static void e1000_receive(struct e1000_dev *e1000) #ifdef CONFIG_NET_IPv6 if (BUF->type == HTONS(ETHTYPE_IP6)) #else - { - if (BUF->type == HTONS(ETHTYPE_IP)) + if (BUF->type == HTONS(ETHTYPE_IP)) #endif + { + arp_ipin(&e1000->netdev); + devif_input(&e1000->netdev); + + /* If the above function invocation resulted in data that should be + * sent out on the network, the field d_len will set to a value > 0. + */ + + if (e1000->netdev.d_len > 0) { - arp_ipin(&e1000->netdev); - devif_input(&e1000->netdev); - - /* If the above function invocation resulted in data that should be - * sent out on the network, the field d_len will set to a value > 0. - */ - - if (e1000->netdev.d_len > 0) - { - arp_out(&e1000->netdev); - e1000_transmit(e1000); - } + arp_out(&e1000->netdev); + e1000_transmit(e1000); } - else if (BUF->type == htons(ETHTYPE_ARP)) + } + else if (BUF->type == htons(ETHTYPE_ARP)) + { + arp_arpin(&e1000->netdev); + + /* If the above function invocation resulted in data that should be + * sent out on the network, the field d_len will set to a value > 0. + */ + + if (e1000->netdev.d_len > 0) { - arp_arpin(&e1000->netdev); - - /* If the above function invocation resulted in data that should be - * sent out on the network, the field d_len will set to a value > 0. - */ - - if (e1000->netdev.d_len > 0) - { - e1000_transmit(e1000); - } + e1000_transmit(e1000); } } diff --git a/drivers/power/max1704x.c b/drivers/power/max1704x.c index fa6f1bb24c..2df676fa61 100644 --- a/drivers/power/max1704x.c +++ b/drivers/power/max1704x.c @@ -271,7 +271,6 @@ static int max1704x_getreg16(FAR struct max1704x_dev_s *priv, uint8_t regaddr, /* Return the 16-bit value */ return (uint16_t)buffer[0] << 8 | (uint16_t)buffer[1]; - return OK; } /**************************************************************************** diff --git a/drivers/power/pm_activity.c b/drivers/power/pm_activity.c index d3c8a52e77..f6dceeea37 100644 --- a/drivers/power/pm_activity.c +++ b/drivers/power/pm_activity.c @@ -156,7 +156,7 @@ void pm_activity(int priority) * controlled priority. */ - (void)pm_update(accum); + (void)pm_update(tmp); } irqrestore(flags); diff --git a/drivers/usbdev/usbmsc_scsi.c b/drivers/usbdev/usbmsc_scsi.c index 78ed8f42cb..0c699bf6bb 100644 --- a/drivers/usbdev/usbmsc_scsi.c +++ b/drivers/usbdev/usbmsc_scsi.c @@ -365,7 +365,7 @@ static void usbmsc_putle32(uint8_t *buf, uint32_t val) static void usbmsc_scsi_wait(FAR struct usbmsc_dev_s *priv) { - irqstate_t flags = irqsave(); + irqstate_t flags; int ret; /* We must hold the SCSI lock to call this function */ @@ -2802,7 +2802,7 @@ int usbmsc_scsi_main(int argc, char *argv[]) void usbmsc_scsi_signal(FAR struct usbmsc_dev_s *priv) { - irqstate_t flags = irqsave(); + irqstate_t flags; /* A flag is used to prevent driving up the semaphore count. This function * is called (primarily) from interrupt level logic so we must disable