chore: cleanup compiler warnings, disable "unaligned pointer value" warning (#5743)

This commit is contained in:
philmoz
2025-01-01 11:33:32 +10:00
committed by GitHub
parent 8c5894af83
commit b6d46325f7
13 changed files with 180 additions and 173 deletions
+2
View File
@@ -8,6 +8,8 @@ if(APPLE)
set(CMAKE_CXX_FLAGS_DEBUG "-Wno-deprecated-declarations")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member")
if(MINGW OR WIN32)
set(CMAKE_OBJECT_PATH_MAX 200)
endif()
+4 -2
View File
@@ -496,7 +496,7 @@ find_program(BASH bash
DOC "bash shell for firmware size report (eg. c:/cygwin/bin/bash.exe on Windows)."
)
set(OPT "s" CACHE STRING "Optimization mode (0/1/2/s")
set(OPT "s" CACHE STRING "Optimization mode (0/1/2/s)")
set(COMMON_FLAGS "-mcpu=${MCU} -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=firmware.lst")
set(COMMON_FLAGS "${COMMON_FLAGS} -gdwarf-2 -fno-exceptions -fdata-sections -ffunction-sections")
@@ -505,7 +505,9 @@ set(COMMON_FLAGS "${COMMON_FLAGS} -O${OPT} ${FPU_FLAGS}")
set(COMMON_FLAGS "${COMMON_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} -Wimplicit")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -fno-rtti")
# "-Wno-register" because ${THIRDPARTY_DIR}/STM32F2xx_HAL_Driver uses invalid C++17 storage class specifier
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -fno-rtti -Wno-register")
if(SDRAM)
# Target with SDRAM do not need a custom allocator for now
-5
View File
@@ -63,11 +63,6 @@ inline unsigned align32(unsigned n)
return rest ? n + 4u - rest : n;
}
inline std::string TEXT_AT_INDEX(const char *const *val, uint8_t idx)
{
return std::string(val[idx]);
}
template<class T>
inline void SWAP(T & a, T & b)
{
+1
View File
@@ -163,6 +163,7 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
#if defined(VIDEO_SWITCH)
bool videoEnabled = false;
#endif
for (uint8_t i=0; i<MAX_SPECIAL_FUNCTIONS; i++) {
CustomFunctionData * cfn = &functions[i];
swsrc_t swtch = CFN_SWITCH(cfn);
@@ -411,7 +411,7 @@ void FunctionEditPage::updateSpecialFunctionOneWindow()
choice->setAvailableHandler(isSourceAvailableInResetSpecialFunction);
choice->setTextHandler([=](int32_t value) {
if (value < FUNC_RESET_PARAM_FIRST_TELEM)
return TEXT_AT_INDEX(STR_VFSWRESET, value);
return std::string(STR_VFSWRESET[value]);
else
return std::string(
g_model.telemetrySensors[value - FUNC_RESET_PARAM_FIRST_TELEM]
+1 -1
View File
@@ -54,7 +54,7 @@ void displayRadioTool(uint8_t index)
g_moduleIdx = reusableBuffer.radioTools.script[index].module;
pushMenu(reusableBuffer.radioTools.script[index].tool);
}
else if (reusableBuffer.radioTools.script[index].path != nullptr) {
else if (reusableBuffer.radioTools.script[index].path[0]) {
char toolName[RADIO_TOOL_NAME_MAXLEN + 1];
if (!readToolName(toolName, reusableBuffer.radioTools.script[index].path)) {
strAppendFilename(toolName, getBasename(reusableBuffer.radioTools.script[index].path), RADIO_TOOL_NAME_MAXLEN);
@@ -102,7 +102,7 @@ void showTelemScreen(uint8_t index)
chainMenu(menuMainView);
} else {
index -= 1;
if ((index >= 0 && index <= TELEMETRY_SCREEN_TYPE_MAX) && (TELEMETRY_SCREEN_TYPE(index) != TELEMETRY_SCREEN_TYPE_NONE)) {
if ((index <= TELEMETRY_SCREEN_TYPE_MAX) && (TELEMETRY_SCREEN_TYPE(index) != TELEMETRY_SCREEN_TYPE_NONE)) {
selectedTelemView = index;
chainMenu(menuViewTelemetry);
}
+6 -3
View File
@@ -92,7 +92,8 @@ void LuaEventHandler::event_cb(lv_event_t* e)
// If we already have a SLIDE going, then accumulate slide values instead
// of allocating an empty slot
if (LuaEventData* const es = luaGetEventSlot(EVT_TOUCH_SLIDE); es) {
LuaEventData* const es = luaGetEventSlot(EVT_TOUCH_SLIDE);
if (es) {
es->event = EVT_TOUCH_SLIDE;
es->touchX = rel_pos.x;
es->touchY = rel_pos.y;
@@ -103,7 +104,8 @@ void LuaEventHandler::event_cb(lv_event_t* e)
TRACE("EVT_TOUCH_SLIDE [%d,%d]", rel_pos.x, rel_pos.y);
}
} else {
if (LuaEventData* const es = luaGetEventSlot(); es) {
LuaEventData* const es = luaGetEventSlot();
if (es) {
es->event = EVT_TOUCH_FIRST;
es->touchX = rel_pos.x;
es->touchY = rel_pos.y;
@@ -116,7 +118,8 @@ void LuaEventHandler::event_cb(lv_event_t* e)
downTime = RTOS_GET_MS();
}
} else if (code == LV_EVENT_RELEASED) {
if (LuaEventData* const es = luaGetEventSlot(); es) {
LuaEventData* const es = luaGetEventSlot();
if (es) {
es->event = EVT_TOUCH_BREAK;
TRACE("EVT_TOUCH_BREAK");
}
+7 -10
View File
@@ -697,19 +697,16 @@ char *getSourceString(char (&destRef)[L], mixsrc_t idx)
if (g_model.scriptsData[qr.quot].name[0] != '\0') {
// instance Name is not empty : dest = InstanceName/OutputName
snprintf(pos, dest_len, "%.*s/%.*s",
(int)sizeof(g_model.scriptsData[qr.quot].name),
g_model.scriptsData[qr.quot].name,
(int)sizeof(scriptInputsOutputs[qr.quot].outputs[qr.rem].name),
scriptInputsOutputs[qr.quot].outputs[qr.rem].name);
pos = strAppend(pos, g_model.scriptsData[qr.quot].name, LEN_SCRIPT_NAME);
} else {
// instance Name is empty : dest = n-ScriptFileName/OutputName
snprintf(pos, dest_len, "%d-%.*s/%.*s", qr.quot + 1,
(int)sizeof(g_model.scriptsData[qr.quot].file),
g_model.scriptsData[qr.quot].file,
(int)sizeof(scriptInputsOutputs[qr.quot].outputs[qr.rem].name),
scriptInputsOutputs[qr.quot].outputs[qr.rem].name);
pos = strAppendUnsigned(pos, qr.quot + 1);
pos = strAppend(pos, "-");
pos = strAppend(pos, g_model.scriptsData[qr.quot].file, LEN_SCRIPT_FILENAME);
}
pos = strAppend(pos, "/");
dest_len = L - (pos - dest);
strAppend(pos, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, dest_len);
}
#else
strncpy(dest, "N/A", dest_len-1);
@@ -111,6 +111,7 @@ const etx_serial_driver_t _fakeSerialDriver = {
.setBaudrateCb = nullptr,
};
#if defined(HARDWARE_EXTERNAL_MODULE)
static void* module_timer_init(void* hw_def, const etx_timer_config_t* cfg)
{ return (void*)1; }
@@ -125,6 +126,7 @@ const etx_timer_driver_t _fakeTimerDriver = {
.deinit = module_timer_deinit,
.send = module_timer_send,
};
#endif
#if defined(HARDWARE_INTERNAL_MODULE)
const etx_module_port_t _internal_ports[] = {
+2
View File
@@ -627,8 +627,10 @@ const etx_serial_driver_t null_drv = {
.setBaudrateCb = nullptr,
};
#if defined(AUX_SERIAL_PWR_GPIO)
static void null_pwr_aux(uint8_t) {}
#endif
#endif
#if defined(AUX_SERIAL)
#if defined(AUX_SERIAL_PWR_GPIO)
+153 -149
View File
@@ -24,15 +24,15 @@
#include "FatFs/ff.h"
#define l_getc(f) fatfs_getc(f)
#define l_lockfile(f) ((void)0)
#define l_unlockfile(f) ((void)0)
// #define l_getc(f) fatfs_getc(f)
// #define l_lockfile(f) ((void)0)
// #define l_unlockfile(f) ((void)0)
static int fatfs_getc(FIL* f) {
char c; UINT result;
if (f_read(f, &c, 1, &result) == FR_OK && result == 1) return c;
return -1;
}
// static int fatfs_getc(FIL* f) {
// char c; UINT result;
// if (f_read(f, &c, 1, &result) == FR_OK && result == 1) return c;
// return -1;
// }
/*
** Change this macro to accept other modes for 'fopen' besides
@@ -61,48 +61,50 @@ static int l_checkmode (const char *mode) {
** =======================================================
*/
// #if !defined(l_popen) /* { */
#if 0
#if !defined(l_popen) /* { */
// #if defined(LUA_USE_POSIX) /* { */
#if defined(LUA_USE_POSIX) /* { */
// #define l_popen(L,c,m) (fflush(NULL), popen(c,m))
// #define l_pclose(L,file) (pclose(file))
#define l_popen(L,c,m) (fflush(NULL), popen(c,m))
#define l_pclose(L,file) (pclose(file))
// #elif defined(LUA_USE_WINDOWS) /* }{ */
#elif defined(LUA_USE_WINDOWS) /* }{ */
// #define l_popen(L,c,m) (_popen(c,m))
// #define l_pclose(L,file) (_pclose(file))
#define l_popen(L,c,m) (_popen(c,m))
#define l_pclose(L,file) (_pclose(file))
// #else /* }{ */
#else /* }{ */
// /* ISO C definitions */
// #define l_popen(L,c,m) \
// ((void)((void)c, m), \
// luaL_error(L, "'popen' not supported"), \
// (FILE*)0)
// #define l_pclose(L,file) ((void)L, (void)file, -1)
/* ISO C definitions */
#define l_popen(L,c,m) \
((void)((void)c, m), \
luaL_error(L, "'popen' not supported"), \
(FILE*)0)
#define l_pclose(L,file) ((void)L, (void)file, -1)
// #endif /* } */
#endif /* } */
// #endif /* } */
#endif /* } */
#endif
/* }====================================================== */
#if 0
#if !defined(l_getc) /* { */
// #if !defined(l_getc) /* { */
// #if defined(LUA_USE_POSIX)
// #define l_getc(f) getc_unlocked(f)
// #define l_lockfile(f) flockfile(f)
// #define l_unlockfile(f) funlockfile(f)
// #else
// #define l_getc(f) getc(f)
// #define l_lockfile(f) ((void)0)
// #define l_unlockfile(f) ((void)0)
// #endif
// #endif /* } */
#if defined(LUA_USE_POSIX)
#define l_getc(f) getc_unlocked(f)
#define l_lockfile(f) flockfile(f)
#define l_unlockfile(f) funlockfile(f)
#else
#define l_getc(f) getc(f)
#define l_lockfile(f) ((void)0)
#define l_unlockfile(f) ((void)0)
#endif
#endif /* } */
#endif
/*
** {======================================================
@@ -110,34 +112,36 @@ static int l_checkmode (const char *mode) {
** =======================================================
*/
// #if !defined(l_fseek) /* { */
#if 0
#if !defined(l_fseek) /* { */
// #if defined(LUA_USE_POSIX) /* { */
#if defined(LUA_USE_POSIX) /* { */
// #include <sys/types.h>
#include <sys/types.h>
// #define l_fseek(f,o,w) fseeko(f,o,w)
// #define l_ftell(f) ftello(f)
// #define l_seeknum off_t
#define l_fseek(f,o,w) fseeko(f,o,w)
#define l_ftell(f) ftello(f)
#define l_seeknum off_t
// #elif defined(LUA_USE_WINDOWS) && !defined(_CRTIMP_TYPEINFO) \
// && defined(_MSC_VER) && (_MSC_VER >= 1400) /* }{ */
#elif defined(LUA_USE_WINDOWS) && !defined(_CRTIMP_TYPEINFO) \
&& defined(_MSC_VER) && (_MSC_VER >= 1400) /* }{ */
// /* Windows (but not DDK) and Visual C++ 2005 or higher */
// #define l_fseek(f,o,w) _fseeki64(f,o,w)
// #define l_ftell(f) _ftelli64(f)
// #define l_seeknum __int64
/* Windows (but not DDK) and Visual C++ 2005 or higher */
#define l_fseek(f,o,w) _fseeki64(f,o,w)
#define l_ftell(f) _ftelli64(f)
#define l_seeknum __int64
// #else /* }{ */
#else /* }{ */
// /* ISO C definitions */
// #define l_fseek(f,o,w) fseek(f,o,w)
// #define l_ftell(f) ftell(f)
// #define l_seeknum long
/* ISO C definitions */
#define l_fseek(f,o,w) fseek(f,o,w)
#define l_ftell(f) ftell(f)
#define l_seeknum long
// #endif /* } */
#endif /* } */
// #endif /* } */
#endif /* } */
#endif
/* }====================================================== */
@@ -206,12 +210,12 @@ static LStream *newprefile (lua_State *L) {
** a bug in some versions of the Clang compiler (e.g., clang 3.0 for
** 32 bits).
*/
static int aux_close (lua_State *L) {
LStream *p = tolstream(L);
volatile lua_CFunction cf = p->closef;
p->closef = NULL; /* mark stream as closed */
return (*cf)(L); /* close it */
}
// static int aux_close (lua_State *L) {
// LStream *p = tolstream(L);
// volatile lua_CFunction cf = p->closef;
// p->closef = NULL; /* mark stream as closed */
// return (*cf)(L); /* close it */
// }
// static int file_close (lua_State *L) {
@@ -285,14 +289,14 @@ static int io_open (lua_State *L) {
? luaL_fileresult(L, 0, filename) : 1;
}
static FIL *getiofile (lua_State *L, const char *findex) {
LStream *p;
lua_getfield(L, LUA_REGISTRYINDEX, findex);
p = (LStream *)lua_touserdata(L, -1);
if (isclosed(p))
luaL_error(L, "standard %s file is closed", findex + IOPREF_LEN);
return &p->f;
}
// static FIL *getiofile (lua_State *L, const char *findex) {
// LStream *p;
// lua_getfield(L, LUA_REGISTRYINDEX, findex);
// p = (LStream *)lua_touserdata(L, -1);
// if (isclosed(p))
// luaL_error(L, "standard %s file is closed", findex + IOPREF_LEN);
// return &p->f;
// }
// static int g_iofile (lua_State *L, const char *f, const char *mode) {
@@ -375,44 +379,44 @@ static FIL *getiofile (lua_State *L, const char *findex) {
*/
static int test_eof (lua_State *L, FIL *f) {
lua_pushliteral(L, "");
return !f_eof(f);
}
// static int test_eof (lua_State *L, FIL *f) {
// lua_pushliteral(L, "");
// return !f_eof(f);
// }
static int read_line (lua_State *L, FIL *f, int chop) {
luaL_Buffer b;
int c = '\0';
luaL_buffinit(L, &b);
while (c != EOF && c != '\n') { /* repeat until end of line */
char *buff = luaL_prepbuffer(&b); /* preallocate buffer */
int i = 0;
l_lockfile(f); /* no memory errors can happen inside the lock */
while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n')
buff[i++] = c;
l_unlockfile(f);
luaL_addsize(&b, i);
}
if (!chop && c == '\n') /* want a newline and have one? */
luaL_addchar(&b, c); /* add ending newline to result */
luaL_pushresult(&b); /* close buffer */
/* return ok if read something (either a newline or something else) */
return (c == '\n' || lua_rawlen(L, -1) > 0);
}
// static int read_line (lua_State *L, FIL *f, int chop) {
// luaL_Buffer b;
// int c = '\0';
// luaL_buffinit(L, &b);
// while (c != EOF && c != '\n') { /* repeat until end of line */
// char *buff = luaL_prepbuffer(&b); /* preallocate buffer */
// int i = 0;
// l_lockfile(f); /* no memory errors can happen inside the lock */
// while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n')
// buff[i++] = c;
// l_unlockfile(f);
// luaL_addsize(&b, i);
// }
// if (!chop && c == '\n') /* want a newline and have one? */
// luaL_addchar(&b, c); /* add ending newline to result */
// luaL_pushresult(&b); /* close buffer */
// /* return ok if read something (either a newline or something else) */
// return (c == '\n' || lua_rawlen(L, -1) > 0);
// }
static void read_all (lua_State *L, FIL *f) {
UINT nr;
luaL_Buffer b;
luaL_buffinit(L, &b);
do { /* read file in chunks of LUAL_BUFFERSIZE bytes */
char *p = luaL_prepbuffer(&b);
if (f_read(f, p, LUAL_BUFFERSIZE, &nr) != FR_OK) nr = 0;
luaL_addsize(&b, nr);
} while (nr == LUAL_BUFFERSIZE);
luaL_pushresult(&b); /* close buffer */
}
// static void read_all (lua_State *L, FIL *f) {
// UINT nr;
// luaL_Buffer b;
// luaL_buffinit(L, &b);
// do { /* read file in chunks of LUAL_BUFFERSIZE bytes */
// char *p = luaL_prepbuffer(&b);
// if (f_read(f, p, LUAL_BUFFERSIZE, &nr) != FR_OK) nr = 0;
// luaL_addsize(&b, nr);
// } while (nr == LUAL_BUFFERSIZE);
// luaL_pushresult(&b); /* close buffer */
// }
static int read_chars (lua_State *L, FIL *f, size_t n) {
@@ -428,51 +432,51 @@ static int read_chars (lua_State *L, FIL *f, size_t n) {
}
static int g_read (lua_State *L, FIL *f, int first) {
int nargs = lua_gettop(L) - 1;
int success;
int n;
f_error(f) = 0;
if (nargs == 0) { /* no arguments? */
success = read_line(L, f, 1);
n = first+1; /* to return 1 result */
}
else { /* ensure stack space for all results and for auxlib's buffer */
luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
success = 1;
for (n = first; nargs-- && success; n++) {
if (lua_type(L, n) == LUA_TNUMBER) {
size_t l = (size_t)luaL_checkinteger(L, n);
success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
}
else {
const char *p = luaL_checkstring(L, n);
if (*p == '*') p++; /* skip optional '*' (for compatibility) */
switch (*p) {
case 'l': /* line */
success = read_line(L, f, 1);
break;
case 'L': /* line with end-of-line */
success = read_line(L, f, 0);
break;
case 'a': /* file */
read_all(L, f); /* read entire file */
success = 1; /* always success */
break;
default:
return luaL_argerror(L, n, "invalid format");
}
}
}
}
if (f_error(f))
return luaL_fileresult(L, 0, NULL);
if (!success) {
lua_pop(L, 1); /* remove last result */
lua_pushnil(L); /* push nil instead */
}
return n - first;
}
// static int g_read (lua_State *L, FIL *f, int first) {
// int nargs = lua_gettop(L) - 1;
// int success;
// int n;
// f_error(f) = 0;
// if (nargs == 0) { /* no arguments? */
// success = read_line(L, f, 1);
// n = first+1; /* to return 1 result */
// }
// else { /* ensure stack space for all results and for auxlib's buffer */
// luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
// success = 1;
// for (n = first; nargs-- && success; n++) {
// if (lua_type(L, n) == LUA_TNUMBER) {
// size_t l = (size_t)luaL_checkinteger(L, n);
// success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
// }
// else {
// const char *p = luaL_checkstring(L, n);
// if (*p == '*') p++; /* skip optional '*' (for compatibility) */
// switch (*p) {
// case 'l': /* line */
// success = read_line(L, f, 1);
// break;
// case 'L': /* line with end-of-line */
// success = read_line(L, f, 0);
// break;
// case 'a': /* file */
// read_all(L, f); /* read entire file */
// success = 1; /* always success */
// break;
// default:
// return luaL_argerror(L, n, "invalid format");
// }
// }
// }
// }
// if (f_error(f))
// return luaL_fileresult(L, 0, NULL);
// if (!success) {
// lua_pop(L, 1); /* remove last result */
// lua_pushnil(L); /* push nil instead */
// }
// return n - first;
// }
// static int io_read (lua_State *L) {
-1
View File
@@ -92,7 +92,6 @@ void checkTrainerSignalWarning()
static void trainer_init_module_sbus();
static void trainer_stop_module_sbus();
static int sbus_trainer_get_byte(uint8_t* data);
void stopTrainer()
{