Skip to content

Commit

Permalink
cpu: Fix array-bounds errors with GCC 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Nohlgård committed Jul 5, 2016
1 parent 7275f98 commit 2e3efb6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 27 deletions.
7 changes: 2 additions & 5 deletions cpu/nrf51/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
#include "periph/adc.h"
#include "periph_conf.h"

#ifdef ADC_CONFIG
/**
* @brief Load the ADC configuration
* @{
*/
#ifdef ADC_CONFIG
static const uint8_t adc_config[] = ADC_CONFIG;
#else
static const uint8_t adc_config[] = {};
#endif

/**
* @brief Lock to prevent concurrency issues when used from different threads
Expand Down Expand Up @@ -91,3 +87,4 @@ int adc_sample(adc_t line, adc_res_t res)

return val;
}
#endif /* ADC_CONFIG */
10 changes: 3 additions & 7 deletions cpu/stm32_common/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

/* only compile this, if the CPU has a DAC */
#if defined(DAC) || defined(DAC1)
#ifdef DAC_CONFIG

#ifdef DAC2
#define _DAC(line) (dac_config[line].dac ? DAC2 : DAC1)
Expand All @@ -34,15 +35,9 @@
#endif

/**
* @brief Get the DAC configuration from the board (if configured)
* @{
* @brief Get the DAC configuration from the board config
*/
#ifdef DAC_CONFIG
static const dac_conf_t dac_config[] = DAC_CONFIG;
#else
static const dac_conf_t dac_config[] = {};
#endif
/** @} */

int8_t dac_init(dac_t line)
{
Expand Down Expand Up @@ -96,4 +91,5 @@ void dac_poweroff(dac_t line)
DAC->CR &= ~(1 << (16 * dac_config[line].chan));
}

#endif /* DAC_CONFIG */
#endif /* DAC */
9 changes: 4 additions & 5 deletions cpu/stm32f0/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@
#include "mutex.h"
#include "periph/adc.h"

#ifdef ADC_CONFIG

/**
* @brief Maximum allowed ADC clock speed
*/
#define MAX_ADC_SPEED (12000000U)

/**
* @brief Load the ADC configuration
* @{
*/
#ifdef ADC_CONFIG
static const adc_conf_t adc_config[] = ADC_CONFIG;
#else
static const adc_conf_t adc_config[] = {};
#endif

/**
* @brief Allocate locks for all three available ADC device
Expand Down Expand Up @@ -105,3 +102,5 @@ int adc_sample(adc_t line, adc_res_t res)

return sample;
}

#endif /* ADC_CONFIG */
9 changes: 4 additions & 5 deletions cpu/stm32f1/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,17 @@
#include "periph/adc.h"
#include "periph_conf.h"

#ifdef ADC_CONFIG

/**
* @brief Maximum allowed ADC clock speed
*/
#define MAX_ADC_SPEED (14000000U)

/**
* @brief Load the ADC configuration
* @{
*/
#ifdef ADC_CONFIG
static const adc_conf_t adc_config[] = ADC_CONFIG;
#else
static const adc_conf_t adc_config[] = {};
#endif

/**
* @brief Allocate locks for all three available ADC devices
Expand Down Expand Up @@ -159,3 +156,5 @@ int adc_sample(adc_t line, adc_res_t res)

return sample;
}

#endif /* ADC_CONFIG */
9 changes: 4 additions & 5 deletions cpu/stm32f4/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@
#include "periph/adc.h"
#include "periph_conf.h"

#ifdef ADC_CONFIG

/**
* @brief Maximum allowed ADC clock speed
*/
#define MAX_ADC_SPEED (12000000U)

/**
* @brief Load the ADC configuration
* @{
*/
#ifdef ADC_CONFIG
static const adc_conf_t adc_config[] = ADC_CONFIG;
#else
static const adc_conf_t adc_config[] = {};
#endif

/**
* @brief Allocate locks for all three available ADC devices
Expand Down Expand Up @@ -124,3 +121,5 @@ int adc_sample(adc_t line, adc_res_t res)

return sample;
}

#endif /* ADC_CONFIG */

0 comments on commit 2e3efb6

Please sign in to comment.