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 13, 2016
1 parent 58baba5 commit 0a847d5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
10 changes: 5 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,7 @@ int adc_sample(adc_t line, adc_res_t res)

return val;
}

#else
typedef int dont_be_pedantic;
#endif /* ADC_CONFIG */
12 changes: 4 additions & 8 deletions cpu/stm32_common/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "periph_conf.h"

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

#ifdef DAC2
#define _DAC(line) (dac_config[line].dac ? DAC2 : DAC1)
Expand All @@ -34,15 +34,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 +90,6 @@ void dac_poweroff(dac_t line)
DAC->CR &= ~(1 << (16 * dac_config[line].chan));
}

#else
typedef int dont_be_pedantic;
#endif /* DAC */
11 changes: 6 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,7 @@ int adc_sample(adc_t line, adc_res_t res)

return sample;
}

#else
typedef int dont_be_pedantic;
#endif /* ADC_CONFIG */
11 changes: 6 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,7 @@ int adc_sample(adc_t line, adc_res_t res)

return sample;
}

#else
typedef int dont_be_pedantic;
#endif /* ADC_CONFIG */
11 changes: 6 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,7 @@ int adc_sample(adc_t line, adc_res_t res)

return sample;
}

#else
typedef int dont_be_pedantic;
#endif /* ADC_CONFIG */

0 comments on commit 0a847d5

Please sign in to comment.