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