mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-30 20:48:33 -04:00
AP_ExternalAHRS: Switch from type punning to defined behavior
* This was undefined behavior in the C++ standard * Use the safer options in AP_Common * Removes a compiler warning Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
This commit is contained in:
parent
d40b02fbbd
commit
d0b8e672c0
@ -575,14 +575,14 @@ float AP_ExternalAHRS_LORD::extract_float(const uint8_t *data, uint8_t offset) c
|
||||
{
|
||||
uint32_t tmp = be32toh_ptr(&data[offset]);
|
||||
|
||||
return *reinterpret_cast<float*>(&tmp);
|
||||
return to_float(tmp);
|
||||
}
|
||||
|
||||
double AP_ExternalAHRS_LORD::extract_double(const uint8_t *data, uint8_t offset) const
|
||||
{
|
||||
uint64_t tmp = be64toh_ptr(&data[offset]);
|
||||
|
||||
return *reinterpret_cast<double*>(&tmp);
|
||||
return to_double(tmp);
|
||||
}
|
||||
|
||||
#endif // AP_EXTERNAL_AHRS_LORD_ENABLE
|
||||
|
Loading…
Reference in New Issue
Block a user