Merge pull request #946 from paparazzi/mpu60x0_ignore_cast_warning

[peripherals] mpuxxxx: 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:
Felix Ruess
2014-11-21 10:36:47 +01:00
4 changed files with 36 additions and 8 deletions
+9 -2
View File
@@ -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;
}
+9 -2
View File
@@ -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;
}
+9 -2
View File
@@ -114,8 +114,15 @@ void mpu9250_i2c_event(struct Mpu9250_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;
}
+9 -2
View File
@@ -114,8 +114,15 @@ void mpu9250_spi_event(struct Mpu9250_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;
}