Various changes and bigfixes for problems detected by CppCheck

This commit is contained in:
Gregory Nutt 2013-05-09 14:23:34 -06:00
parent cb5fa55663
commit 98787f4717
5 changed files with 25 additions and 8 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/imx/imx_spi.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -728,9 +728,12 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency)
{
struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
uint32_t actual = priv->actual;
uint32_t actual;
if (priv && frequency != priv->frequency)
DEBUGASSERT(priv);
actual = priv->actual;
if (frequency != priv->frequency)
{
uint32_t freqbits;
uint32_t regval;

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_pindma.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 201, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -84,6 +84,10 @@ void kinetis_pindmaenable(uint32_t pinset)
DEBUGASSERT(port < KINETIS_NPORTS);
if (port < KINETIS_NPORTS)
{
/* Get the base address of PORT block for this port */
base = KINETIS_PORT_BASE(port);
/* Modify the IRQC field of the port PCR register in order to enable DMA. */
regval = getreg32(base + KINETIS_PORT_PCR_OFFSET(pin));
@ -134,6 +138,10 @@ void kinetis_pindmadisable(uint32_t pinset)
DEBUGASSERT(port < KINETIS_NPORTS);
if (port < KINETIS_NPORTS)
{
/* Get the base address of PORT block for this port */
base = KINETIS_PORT_BASE(port);
/* Clear the IRQC field of the port PCR register in order to disable DMA. */
regval = getreg32(base + KINETIS_PORT_PCR_OFFSET(pin));

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_pinirq.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without

View File

@ -313,7 +313,8 @@ typedef uint32_t gpio_cfgset_t;
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
@ -353,5 +354,9 @@ void kl_gpiowrite(uint32_t pinset, bool value);
bool kl_gpioread(uint32_t pinset);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_KL_KINETIS_GPIO_H */

View File

@ -80,11 +80,10 @@ void up_lowserialinit(void)
uint8_t val;
#ifdef CONFIG_UART0_SERIAL_CONSOLE
/* Set the baudrate */
brg = (freq +(uint32_t)CONFIG_UART0_BAUD * 8) /((uint32_t)CONFIG_UART0_BAUD * 16) ;
/* Set the baudrate */
putreg8(brg >> 8, U0BRH);
putreg8(brg & 0xff, U0BRL);
@ -107,6 +106,8 @@ void up_lowserialinit(void)
#elif defined(EZ8_UART1) && defined(CONFIG_UART1_SERIAL_CONSOLE)
/* Set the baudrate */
brg = (freq +(uint32_t)CONFIG_UART1_BAUD * 8) /((uint32_t)CONFIG_UART1_BAUD * 16) ;
putreg8(brg >> 8, U1BRH);
putreg8(brg & 0xff, U1BRL);