1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Fix clang warnings (#4988)

* Fix clang warnings

- signed char on AVR vs unsigned char on ARM
- use references instead of points in calculation (same code size)
- Ignore packed address warning for mavlink includes
- Turn error on packed addresses to warning for Horus (Cannot fix that without major refactoring, might even need eeprom change)

* Revert fixes for clang on AVR as the old AVR gcc does not like them
This commit is contained in:
Arne Schwabe 2017-07-30 09:59:15 +02:00 committed by Bertrand Songis
parent 3436273fdf
commit a7524ba74d
3 changed files with 21 additions and 1 deletions

View file

@ -2483,7 +2483,18 @@ void opentxInit(OPENTX_INIT_ARGS)
// g_model.topbarData is still zero here (because it was not yet read from SDCARD), // g_model.topbarData is still zero here (because it was not yet read from SDCARD),
// but we only remember the pointer to in in constructor. // but we only remember the pointer to in in constructor.
// The storageReadAll() needs topbar object, so it must be created here // The storageReadAll() needs topbar object, so it must be created here
#if __clang__
// clang does not like this at all, turn into a warning so that -Werror does not stop here
// taking address of packed member 'topbarData' of class or structure 'ModelData' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Waddress-of-packed-member"
#endif
topbar = new Topbar(&g_model.topbarData); topbar = new Topbar(&g_model.topbarData);
#if __clang__
// Restore warnings
#pragma clang diagnostic pop
#endif
// lua widget state must also be prepared before the call to storageReadAll() // lua widget state must also be prepared before the call to storageReadAll()
LUA_INIT_THEMES_AND_WIDGETS(); LUA_INIT_THEMES_AND_WIDGETS();
} }

View file

@ -32,7 +32,7 @@ const char * writeFile(const char * filename, const uint8_t * data, uint16_t siz
TRACE("writeFile(%s)", filename); TRACE("writeFile(%s)", filename);
FIL file; FIL file;
char buf[8]; unsigned char buf[8];
UINT written; UINT written;
FRESULT result = f_open(&file, filename, FA_CREATE_ALWAYS | FA_WRITE); FRESULT result = f_open(&file, filename, FA_CREATE_ALWAYS | FA_WRITE);

View file

@ -48,7 +48,16 @@ extern void SERIAL_send_uart_bytes(const uint8_t * buf, uint16_t len);
#define MAVLINK_END_UART_SEND(chan,len) SERIAL_end_uart_send() #define MAVLINK_END_UART_SEND(chan,len) SERIAL_end_uart_send()
#define MAVLINK_SEND_UART_BYTES(chan,buf,len) SERIAL_send_uart_bytes(buf,len) #define MAVLINK_SEND_UART_BYTES(chan,buf,len) SERIAL_send_uart_bytes(buf,len)
#if __clang__
// clang does not like packed member access at all. Since mavlink is a 3rd party library, ignore the errors
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Waddress-of-packed-member"
#endif
#include "GCS_MAVLink/include_v1.0/ardupilotmega/mavlink.h" #include "GCS_MAVLink/include_v1.0/ardupilotmega/mavlink.h"
#if __clang__
// Restore warnings about packed member access
#pragma clang diagnostic pop
#endif
//#define MAVLINK_PARAMS //#define MAVLINK_PARAMS
//#define DUMP_RX_TX //#define DUMP_RX_TX