mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 17:06:31 +08:00
[peripherals] mpu60x0: use gcc pragma to ignore cast-qual warnings
The buffer is volatile, since filled from ISR... But we know it's ok to use it here so we silence the warning. Also there is a bug in some gcc version that incorrectly reports this as peripherals/mpu60x0_spi.c:118:33: warning: cast discards '__attribute__((noreturn))' qualifier from pointer target type [-Wcast-qual] see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383
This commit is contained in:
committed by
Gautier Hattenberger
parent
4258f43206
commit
fadb06771f
@@ -96,8 +96,15 @@ void mpu60x0_i2c_event(struct Mpu60x0_I2c *mpu)
|
||||
mpu->data_rates.rates.r = Int16FromBuf(mpu->i2c_trans.buf, 13);
|
||||
|
||||
// if we are reading slaves through the mpu, copy the ext_sens_data
|
||||
if ((mpu->config.i2c_bypass == FALSE) && (mpu->config.nb_slaves > 0))
|
||||
memcpy(mpu->data_ext, (void *) &(mpu->i2c_trans.buf[15]), mpu->config.nb_bytes - 15);
|
||||
if ((mpu->config.i2c_bypass == FALSE) && (mpu->config.nb_slaves > 0)) {
|
||||
/* the buffer is volatile, since filled from ISR
|
||||
* but we know it's ok to use it here so we silence the warning
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
memcpy(mpu->data_ext, (uint8_t*)&(mpu->i2c_trans.buf[15]), mpu->config.nb_bytes - 15);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
mpu->data_available = TRUE;
|
||||
}
|
||||
|
||||
@@ -114,8 +114,15 @@ void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
|
||||
mpu->data_rates.rates.r = Int16FromBuf(mpu->rx_buf, 14);
|
||||
|
||||
// if we are reading slaves, copy the ext_sens_data
|
||||
if (mpu->config.nb_slaves > 0)
|
||||
memcpy(mpu->data_ext, (void *) &(mpu->rx_buf[16]), mpu->config.nb_bytes - 15);
|
||||
if (mpu->config.nb_slaves > 0) {
|
||||
/* the buffer is volatile, since filled from ISR
|
||||
* but we know it's ok to use it here so we silence the warning
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
memcpy(mpu->data_ext, (uint8_t*)&(mpu->rx_buf[16]), mpu->config.nb_bytes - 15);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
mpu->data_available = TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user