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

Replace NULL by nullptr

This commit is contained in:
Bertrand Songis 2019-08-28 10:28:11 +02:00
parent c8482905a0
commit e7736f3fdc
No known key found for this signature in database
GPG key ID: F189F79290FEC50F
28 changed files with 66 additions and 85 deletions

View file

@ -97,7 +97,7 @@ void *bin_l_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
free(ptr); free(ptr);
} }
} }
return NULL; return nullptr;
} }
else { else {
#if defined(DEBUG) #if defined(DEBUG)

View file

@ -95,7 +95,7 @@ char * Bluetooth::readline(bool error_reset)
state = BLUETOOTH_STATE_OFF; state = BLUETOOTH_STATE_OFF;
wakeupTime = get_tmr10ms() + 100; /* 1s */ wakeupTime = get_tmr10ms() + 100; /* 1s */
#endif #endif
return NULL; return nullptr;
} }
else else
#endif #endif

View file

@ -70,7 +70,7 @@ int toLongLongInt(const char ** argv, int index, long long int * val)
base = 16; base = 16;
s = &argv[index][2]; s = &argv[index][2];
} }
char * endptr = NULL; char * endptr = nullptr;
*val = strtoll(s, &endptr, base); *val = strtoll(s, &endptr, base);
if (*endptr == '\0') if (*endptr == '\0')
return 1; return 1;
@ -782,7 +782,7 @@ const MemArea memAreas[] = {
{ "USART1", USART1, sizeof(USART_TypeDef) }, { "USART1", USART1, sizeof(USART_TypeDef) },
{ "USART2", USART2, sizeof(USART_TypeDef) }, { "USART2", USART2, sizeof(USART_TypeDef) },
{ "USART3", USART3, sizeof(USART_TypeDef) }, { "USART3", USART3, sizeof(USART_TypeDef) },
{ NULL, NULL, 0 }, { nullptr, nullptr, 0 },
}; };
int cliSet(const char ** argv) int cliSet(const char ** argv)
@ -947,7 +947,7 @@ int cliDisplay(const char ** argv)
{ {
long long int address = 0; long long int address = 0;
for (const MemArea * area = memAreas; area->name != NULL; area++) { for (const MemArea * area = memAreas; area->name != nullptr; area++) {
if (!strcmp(area->name, argv[1])) { if (!strcmp(area->name, argv[1])) {
dump((uint8_t *)area->start, area->size); dump((uint8_t *)area->start, area->size);
return 0; return 0;
@ -1218,12 +1218,12 @@ const CliCommand cliCommands[] = {
#if defined(BLUETOOTH) #if defined(BLUETOOTH)
{ "bt", cliBlueTooth, "<baudrate>|<command>" }, { "bt", cliBlueTooth, "<baudrate>|<command>" },
#endif #endif
{ NULL, NULL, NULL } /* sentinel */ { nullptr, nullptr, nullptr } /* sentinel */
}; };
int cliHelp(const char ** argv) int cliHelp(const char ** argv)
{ {
for (const CliCommand * command = cliCommands; command->name != NULL; command++) { for (const CliCommand * command = cliCommands; command->name != nullptr; command++) {
if (argv[1][0] == '\0' || !strcmp(command->name, argv[0])) { if (argv[1][0] == '\0' || !strcmp(command->name, argv[0])) {
serialPrint("%s %s", command->name, command->args); serialPrint("%s %s", command->name, command->args);
if (argv[1][0] != '\0') { if (argv[1][0] != '\0') {
@ -1242,7 +1242,7 @@ int cliExecCommand(const char ** argv)
if (argv[0][0] == '\0') if (argv[0][0] == '\0')
return 0; return 0;
for (const CliCommand * command = cliCommands; command->name != NULL; command++) { for (const CliCommand * command = cliCommands; command->name != nullptr; command++) {
if (!strcmp(command->name, argv[0])) { if (!strcmp(command->name, argv[0])) {
return command->func(argv); return command->func(argv);
} }

View file

@ -33,7 +33,7 @@ void onModelCustomScriptMenu(const char *result)
ScriptData &sd = g_model.scriptsData[s_currIdx]; ScriptData &sd = g_model.scriptsData[s_currIdx];
if (result == STR_UPDATE_LIST) { if (result == STR_UPDATE_LIST) {
if (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) { if (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), nullptr)) {
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
} }
} }

View file

@ -31,7 +31,7 @@ const unsigned char sticks[] = {
#define SLIDER_5POS(y, value, label, event, attr) { \ #define SLIDER_5POS(y, value, label, event, attr) { \
int8_t tmp = value; \ int8_t tmp = value; \
drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, 2+tmp, 4, attr); \ drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, 2+tmp, 4, attr); \
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, nullptr, tmp, -2, +2, attr, event); \
} }
#if defined(SPLASH) #if defined(SPLASH)

View file

@ -550,7 +550,7 @@ void menuMainView(event_t event)
lcdDrawText(lcdLastRightPos, 5*FH, "%", BOLD); lcdDrawText(lcdLastRightPos, 5*FH, "%", BOLD);
} }
lcdDrawText(lcdLastRightPos, 5*FH, "]", BOLD); lcdDrawText(lcdLastRightPos, 5*FH, "]", BOLD);
warningText = NULL; warningText = nullptr;
} }
#endif #endif

View file

@ -143,7 +143,7 @@ void copySelection(char * dst, const char * src, uint8_t size)
void onModelSetupBitmapMenu(const char * result) void onModelSetupBitmapMenu(const char * result)
{ {
if (result == STR_UPDATE_LIST) { if (result == STR_UPDATE_LIST) {
if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), NULL)) { if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), nullptr)) {
POPUP_WARNING(STR_NO_BITMAPS_ON_SD); POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
} }
} }

View file

@ -52,7 +52,7 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
strcpy(directory, SOUNDS_PATH); strcpy(directory, SOUNDS_PATH);
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
} }
if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), NULL)) { if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), nullptr)) {
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD); POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
} }
} }

View file

@ -33,7 +33,7 @@ const unsigned char sticks[] = {
#define SLIDER_5POS(y, value, label, event, attr) { \ #define SLIDER_5POS(y, value, label, event, attr) { \
int8_t tmp = value; \ int8_t tmp = value; \
drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, nullptr, tmp, -2, +2, attr, event); \
} }
#if defined(SPLASH) #if defined(SPLASH)

View file

@ -92,7 +92,7 @@ choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label, LcdFlags attr, event_t event ) uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label, LcdFlags attr, event_t event )
{ {
drawCheckBox(x, y, value, attr); drawCheckBox(x, y, value, attr);
return editChoice(x, y, label, NULL, value, 0, 1, attr, event); return editChoice(x, y, label, nullptr, value, 0, 1, attr, event);
} }
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event) swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event)

View file

@ -36,7 +36,7 @@ extern "C" {
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100) #define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100)
#define LUA_WARNING_INFO_LEN 64 #define LUA_WARNING_INFO_LEN 64
lua_State *lsScripts = NULL; lua_State *lsScripts = nullptr;
uint8_t luaState = 0; uint8_t luaState = 0;
uint8_t luaScriptsCount = 0; uint8_t luaScriptsCount = 0;
ScriptInternalData scriptInternalData[MAX_SCRIPTS]; ScriptInternalData scriptInternalData[MAX_SCRIPTS];
@ -256,7 +256,7 @@ void luaClose(lua_State ** L)
if (*L == lsScripts) luaDisable(); if (*L == lsScripts) luaDisable();
} }
UNPROTECT_LUA(); UNPROTECT_LUA();
*L = NULL; *L = nullptr;
} }
} }
@ -362,7 +362,7 @@ static void luaDumpState(lua_State * L, const char * filename, const FILINFO * f
luaU_dump(L, getproto(L->top - 1), luaDumpWriter, &D, stripDebug); luaU_dump(L, getproto(L->top - 1), luaDumpWriter, &D, stripDebug);
lua_unlock(L); lua_unlock(L);
if (f_close(&D) == FR_OK) { if (f_close(&D) == FR_OK) {
if (finfo != NULL) if (finfo != nullptr)
f_utime(filename, finfo); // set the file mod time f_utime(filename, finfo); // set the file mod time
TRACE("luaDumpState(%s): Saved bytecode to file.", filename); TRACE("luaDumpState(%s): Saved bytecode to file.", filename);
} }
@ -404,7 +404,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
{ {
if (luaState == INTERPRETER_PANIC) { if (luaState == INTERPRETER_PANIC) {
return SCRIPT_PANIC; return SCRIPT_PANIC;
} else if (filename == NULL) { } else if (filename == nullptr) {
return SCRIPT_NOFILE; return SCRIPT_NOFILE;
} }
@ -412,7 +412,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
char lmode[6] = "bt"; char lmode[6] = "bt";
uint8_t ret = SCRIPT_NOFILE; uint8_t ret = SCRIPT_NOFILE;
if (mode != NULL) { if (mode != nullptr) {
strncpy(lmode, mode, sizeof(lmode)-1); strncpy(lmode, mode, sizeof(lmode)-1);
lmode[sizeof(lmode)-1] = '\0'; lmode[sizeof(lmode)-1] = '\0';
} }
@ -432,7 +432,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
fnamelen = strlen(filename); fnamelen = strlen(filename);
// check if file extension is already in the file name and strip it // check if file extension is already in the file name and strip it
getFileExtension(filename, fnamelen, 0, NULL, &extlen); getFileExtension(filename, fnamelen, 0, nullptr, &extlen);
fnamelen -= extlen; fnamelen -= extlen;
if (fnamelen > sizeof(filenameFull) - sizeof(SCRIPT_BIN_EXT)) { if (fnamelen > sizeof(filenameFull) - sizeof(SCRIPT_BIN_EXT)) {
TRACE_ERROR("luaLoadScriptFileToState(%s, %s): Error loading script: filename buffer overflow.\n", filename, lmode); TRACE_ERROR("luaLoadScriptFileToState(%s, %s): Error loading script: filename buffer overflow.\n", filename, lmode);
@ -507,7 +507,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
TRACE("luaLoadScriptFileToState(%s, %s): loading %s", filename, lmode, filenameFull); TRACE("luaLoadScriptFileToState(%s, %s): loading %s", filename, lmode, filenameFull);
// we don't pass <mode> on to loadfilex() because we want lua to load whatever file we specify, regardless of content // we don't pass <mode> on to loadfilex() because we want lua to load whatever file we specify, regardless of content
lstatus = luaL_loadfilex(L, filenameFull, NULL); lstatus = luaL_loadfilex(L, filenameFull, nullptr);
#if defined(LUA_COMPILER) #if defined(LUA_COMPILER)
// Check for bytecode encoding problem, eg. compiled for x64. Unfortunately Lua doesn't provide a unique error code for this. See Lua/src/lundump.c. // Check for bytecode encoding problem, eg. compiled for x64. Unfortunately Lua doesn't provide a unique error code for this. See Lua/src/lundump.c.
if (lstatus == LUA_ERRSYNTAX && loadFileType == 2 && frLuaS == FR_OK && strstr(lua_tostring(L, -1), "precompiled")) { if (lstatus == LUA_ERRSYNTAX && loadFileType == 2 && frLuaS == FR_OK && strstr(lua_tostring(L, -1), "precompiled")) {
@ -515,7 +515,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
scriptNeedsCompile = true; scriptNeedsCompile = true;
strcpy(filenameFull + fnamelen, SCRIPT_EXT); strcpy(filenameFull + fnamelen, SCRIPT_EXT);
TRACE_ERROR("luaLoadScriptFileToState(%s, %s): Error loading script: %s\n\tRetrying with %s\n", filename, lmode, lua_tostring(L, -1), filenameFull); TRACE_ERROR("luaLoadScriptFileToState(%s, %s): Error loading script: %s\n\tRetrying with %s\n", filename, lmode, lua_tostring(L, -1), filenameFull);
lstatus = luaL_loadfilex(L, filenameFull, NULL); lstatus = luaL_loadfilex(L, filenameFull, nullptr);
} }
if (lstatus == LUA_OK) { if (lstatus == LUA_OK) {
if (scriptNeedsCompile && loadFileType == 1) { if (scriptNeedsCompile && loadFileType == 1) {
@ -545,7 +545,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
return ret; return ret;
} }
static int luaLoad(lua_State * L, const char * filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=NULL) static int luaLoad(lua_State * L, const char * filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=nullptr)
{ {
int init = 0; int init = 0;
int lstatus = 0; int lstatus = 0;
@ -910,7 +910,7 @@ bool luaDoOneRunPermanentScript(event_t evt, int i, uint32_t scriptType)
#if defined(SIMU) || defined(DEBUG) #if defined(SIMU) || defined(DEBUG)
const char *filename; const char *filename;
#endif #endif
ScriptInputsOutputs * sio = NULL; ScriptInputsOutputs * sio = nullptr;
#if SCRIPT_MIX_FIRST > 0 #if SCRIPT_MIX_FIRST > 0
if ((scriptType & RUN_MIX_SCRIPT) && (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST)) { if ((scriptType & RUN_MIX_SCRIPT) && (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST)) {
#else #else
@ -1082,13 +1082,13 @@ void luaInit()
if (luaState != INTERPRETER_PANIC) { if (luaState != INTERPRETER_PANIC) {
#if defined(USE_BIN_ALLOCATOR) #if defined(USE_BIN_ALLOCATOR)
lsScripts = lua_newstate(bin_l_alloc, NULL); //we use our own allocator! lsScripts = lua_newstate(bin_l_alloc, nullptr); //we use our own allocator!
#elif defined(LUA_ALLOCATOR_TRACER) #elif defined(LUA_ALLOCATOR_TRACER)
memset(&lsScriptsTrace, 0 , sizeof(lsScriptsTrace)); memset(&lsScriptsTrace, 0 , sizeof(lsScriptsTrace));
lsScriptsTrace.script = "lua_newstate(scripts)"; lsScriptsTrace.script = "lua_newstate(scripts)";
lsScripts = lua_newstate(tracer_alloc, &lsScriptsTrace); //we use tracer allocator lsScripts = lua_newstate(tracer_alloc, &lsScriptsTrace); //we use tracer allocator
#else #else
lsScripts = lua_newstate(l_alloc, NULL); //we use Lua default allocator lsScripts = lua_newstate(l_alloc, nullptr); //we use Lua default allocator
#endif #endif
if (lsScripts) { if (lsScripts) {
// install our panic handler // install our panic handler

View file

@ -2048,7 +2048,7 @@ uint32_t pwrPressedDuration()
uint32_t pwrCheck() uint32_t pwrCheck()
{ {
const char * message = NULL; const char * message = nullptr;
enum PwrCheckState { enum PwrCheckState {
PWR_CHECK_ON, PWR_CHECK_ON,

View file

@ -1210,7 +1210,7 @@ extern union ReusableBuffer reusableBuffer;
uint8_t zlen(const char *str, uint8_t size); uint8_t zlen(const char *str, uint8_t size);
bool zexist(const char *str, uint8_t size); bool zexist(const char *str, uint8_t size);
unsigned int effectiveLen(const char * str, unsigned int size); unsigned int effectiveLen(const char * str, unsigned int size);
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defaultName=NULL, uint8_t defaultNameSize=0, uint8_t defaultIdx=0); char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defaultName=nullptr, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
#define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, STR_FM, PSIZE(TR_FM), idx+1) #define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, STR_FM, PSIZE(TR_FM), idx+1)
#if defined(EEPROM) #if defined(EEPROM)
#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1) #define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1)

View file

@ -68,7 +68,7 @@ const char * sdCheckAndCreateDirectory(const char * path)
f_closedir(&archiveFolder); f_closedir(&archiveFolder);
} }
return NULL; return nullptr;
} }
bool isFileAvailable(const char * path, bool exclDir) bool isFileAvailable(const char * path, bool exclDir)
@ -95,7 +95,7 @@ bool isFileAvailable(const char * path, bool exclDir)
@param match Optional container to hold the matched file extension (wide enough to hold LEN_FILE_EXTENSION_MAX + 1). @param match Optional container to hold the matched file extension (wide enough to hold LEN_FILE_EXTENSION_MAX + 1).
@retval true if a file was found, false otherwise. @retval true if a file was found, false otherwise.
*/ */
bool isFilePatternAvailable(const char * path, const char * file, const char * pattern = NULL, bool exclDir = true, char * match = NULL) bool isFilePatternAvailable(const char * path, const char * file, const char * pattern = nullptr, bool exclDir = true, char * match = nullptr)
{ {
uint8_t fplen; uint8_t fplen;
char fqfp[LEN_FILE_PATH_MAX + _MAX_LFN + 1] = "\0"; char fqfp[LEN_FILE_PATH_MAX + _MAX_LFN + 1] = "\0";
@ -110,7 +110,7 @@ bool isFilePatternAvailable(const char * path, const char * file, const char * p
strcpy(fqfp + fplen, "/"); strcpy(fqfp + fplen, "/");
strncat(fqfp + (++fplen), file, _MAX_LFN); strncat(fqfp + (++fplen), file, _MAX_LFN);
if (pattern == NULL) { if (pattern == nullptr) {
// no extensions list, just check the filename as-is // no extensions list, just check the filename as-is
return isFileAvailable(fqfp, exclDir); return isFileAvailable(fqfp, exclDir);
} }
@ -129,13 +129,13 @@ bool isFilePatternAvailable(const char * path, const char * file, const char * p
while (plen > 0 && ext) { while (plen > 0 && ext) {
strncat(fqfp + len, ext, extlen); strncat(fqfp + len, ext, extlen);
if (isFileAvailable(fqfp, exclDir)) { if (isFileAvailable(fqfp, exclDir)) {
if (match != NULL) strncat(&(match[0]='\0'), ext, extlen); if (match != nullptr) strncat(&(match[0]='\0'), ext, extlen);
return true; return true;
} }
plen -= extlen; plen -= extlen;
if (plen > 0) { if (plen > 0) {
fqfp[len] = '\0'; fqfp[len] = '\0';
ext = getFileExtension(pattern, plen, 0, NULL, &extlen); ext = getFileExtension(pattern, plen, 0, nullptr, &extlen);
} }
} }
} }
@ -147,7 +147,7 @@ char * getFileIndex(char * filename, unsigned int & value)
value = 0; value = 0;
char * pos = (char *)getFileExtension(filename); char * pos = (char *)getFileExtension(filename);
if (!pos || pos == filename) if (!pos || pos == filename)
return NULL; return nullptr;
int multiplier = 1; int multiplier = 1;
while (pos > filename) { while (pos > filename) {
pos--; pos--;
@ -179,7 +179,7 @@ int findNextFileIndex(char * filename, uint8_t size, const char * directory)
uint8_t extlen; uint8_t extlen;
char * indexPos = getFileIndex(filename, index); char * indexPos = getFileIndex(filename, index);
char extension[LEN_FILE_EXTENSION_MAX+1] = "\0"; char extension[LEN_FILE_EXTENSION_MAX+1] = "\0";
char * p = (char *)getFileExtension(filename, 0, 0, NULL, &extlen); char * p = (char *)getFileExtension(filename, 0, 0, nullptr, &extlen);
if (p) strncat(extension, p, sizeof(extension)-1); if (p) strncat(extension, p, sizeof(extension)-1);
while (1) { while (1) {
index++; index++;
@ -188,7 +188,7 @@ int findNextFileIndex(char * filename, uint8_t size, const char * directory)
} }
char * pos = strAppendUnsigned(indexPos, index); char * pos = strAppendUnsigned(indexPos, index);
strAppend(pos, extension); strAppend(pos, extension);
if (!isFilePatternAvailable(directory, filename, NULL, false)) { if (!isFilePatternAvailable(directory, filename, nullptr, false)) {
return index; return index;
} }
} }
@ -249,12 +249,12 @@ bool isExtensionMatching(const char * extension, const char * pattern, char * ma
plen = (int)fnlen; plen = (int)fnlen;
while (plen > 0 && ext) { while (plen > 0 && ext) {
if (!strncasecmp(extension, ext, extlen)) { if (!strncasecmp(extension, ext, extlen)) {
if (match != NULL) strncat(&(match[0]='\0'), ext, extlen); if (match != nullptr) strncat(&(match[0]='\0'), ext, extlen);
return true; return true;
} }
plen -= extlen; plen -= extlen;
if (plen > 0) { if (plen > 0) {
ext = getFileExtension(pattern, plen, 0, NULL, &extlen); ext = getFileExtension(pattern, plen, 0, nullptr, &extlen);
} }
} }
return false; return false;
@ -275,7 +275,7 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen
if (selection) { if (selection) {
s_last_flags = flags; s_last_flags = flags;
if (!isFilePatternAvailable(path, selection, ((flags & LIST_SD_FILE_EXT) ? NULL : extension))) selection = NULL; if (!isFilePatternAvailable(path, selection, ((flags & LIST_SD_FILE_EXT) ? nullptr : extension))) selection = nullptr;
} }
else { else {
flags = s_last_flags; flags = s_last_flags;
@ -475,7 +475,7 @@ const char * sdCopyFile(const char * srcPath, const char * destPath)
return SDCARD_ERROR(result); return SDCARD_ERROR(result);
} }
return NULL; return nullptr;
} }
const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir) const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir)

View file

@ -14,7 +14,6 @@ option(DSM2 "DSM2 TX Module" ON)
option(SBUS "SBUS TX Module" ON) option(SBUS "SBUS TX Module" ON)
option(CROSSFIRE "Crossfire TX Module" ON) option(CROSSFIRE "Crossfire TX Module" ON)
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON) option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON)
option(MULTI_SPORT "SPORT telemetry support" OFF)
option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY
option(DEBUG_INTERRUPTS "Count interrupts" OFF) option(DEBUG_INTERRUPTS "Count interrupts" OFF)
option(DEBUG_LATENCY "Debug latency" OFF) option(DEBUG_LATENCY "Debug latency" OFF)
@ -152,10 +151,6 @@ if(MULTIMODULE)
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp) set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp)
endif() endif()
if(MULTI_SPORT)
add_definitions(-DMULTI_SPORT)
endif()
if(CROSSFIRE) if(CROSSFIRE)
add_definitions(-DCROSSFIRE) add_definitions(-DCROSSFIRE)
set(PULSES_SRC set(PULSES_SRC

View file

@ -378,7 +378,7 @@ void audioInit()
audioSendRiffHeader(); audioSendRiffHeader();
} }
uint8_t * currentBuffer = NULL; uint8_t * currentBuffer = nullptr;
uint32_t currentSize = 0; uint32_t currentSize = 0;
int16_t newVolume = -1; int16_t newVolume = -1;
@ -389,7 +389,7 @@ void audioSetCurrentBuffer(const AudioBuffer * buffer)
currentSize = buffer->size * 2; currentSize = buffer->size * 2;
} }
else { else {
currentBuffer = NULL; currentBuffer = nullptr;
currentSize = 0; currentSize = 0;
} }
} }
@ -413,7 +413,7 @@ void audioConsumeCurrentBuffer()
currentSize -= written; currentSize -= written;
if (currentSize == 0) { if (currentSize == 0) {
audioQueue.buffersFifo.freeNextFilledBuffer(); audioQueue.buffersFifo.freeNextFilledBuffer();
currentBuffer = NULL; currentBuffer = nullptr;
currentSize = 0; currentSize = 0;
} }
} }

View file

@ -365,7 +365,7 @@ void sdDone()
#if defined(LOG_TELEMETRY) #if defined(LOG_TELEMETRY)
f_close(&g_telemetryFile); f_close(&g_telemetryFile);
#endif #endif
f_mount(NULL, "", 0); // unmount SD f_mount(nullptr, "", 0); // unmount SD
} }
} }
#endif #endif

View file

@ -52,7 +52,7 @@ void firmwareTraceCb(const char * text)
OpenTxSimulator::OpenTxSimulator() : OpenTxSimulator::OpenTxSimulator() :
SimulatorInterface(), SimulatorInterface(),
m_timer10ms(NULL), m_timer10ms(nullptr),
m_resetOutputsData(true), m_resetOutputsData(true),
m_stopRequested(false) m_stopRequested(false)
{ {
@ -62,7 +62,7 @@ OpenTxSimulator::OpenTxSimulator() :
OpenTxSimulator::~OpenTxSimulator() OpenTxSimulator::~OpenTxSimulator()
{ {
traceCallback = NULL; traceCallback = nullptr;
tracebackDevices.clear(); tracebackDevices.clear();
if (m_timer10ms) if (m_timer10ms)

View file

@ -51,7 +51,7 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface
public slots: public slots:
virtual void init(); virtual void init();
virtual void start(const char * filename = NULL, bool tests = true); virtual void start(const char * filename = nullptr, bool tests = true);
virtual void stop(); virtual void stop();
virtual void setSdPath(const QString & sdPath = "", const QString & settingsPath = ""); virtual void setSdPath(const QString & sdPath = "", const QString & settingsPath = "");
virtual void setVolumeGain(const int value); virtual void setVolumeGain(const int value);

View file

@ -220,8 +220,8 @@ void StopSimu()
simu_shutdown = true; simu_shutdown = true;
pthread_join(mixerTaskId, NULL); pthread_join(mixerTaskId, nullptr);
pthread_join(menusTaskId, NULL); pthread_join(menusTaskId, nullptr);
simu_running = false; simu_running = false;
} }
@ -348,7 +348,7 @@ void * audioThread(void *)
wanted.channels = 1; /* 1 = mono, 2 = stereo */ wanted.channels = 1; /* 1 = mono, 2 = stereo */
wanted.samples = AUDIO_BUFFER_SIZE*2; /* Good low-latency value for callback */ wanted.samples = AUDIO_BUFFER_SIZE*2; /* Good low-latency value for callback */
wanted.callback = fillAudioBuffer; wanted.callback = fillAudioBuffer;
wanted.userdata = NULL; wanted.userdata = nullptr;
/* /*
SDL_OpenAudio() internally calls SDL_InitSubSystem(SDL_INIT_AUDIO), SDL_OpenAudio() internally calls SDL_InitSubSystem(SDL_INIT_AUDIO),
@ -390,7 +390,7 @@ void StartAudioThread(int volumeGain)
void StopAudioThread() void StopAudioThread()
{ {
simuAudio.threadRunning = false; simuAudio.threadRunning = false;
pthread_join(simuAudio.threadPid, NULL); pthread_join(simuAudio.threadPid, nullptr);
} }
#endif // #if defined(SIMU_AUDIO) #endif // #if defined(SIMU_AUDIO)

View file

@ -361,7 +361,7 @@ TCHAR * f_gets (TCHAR* buff, int len, FIL* fil)
{ {
if (fil && fil->obj.fs) { if (fil && fil->obj.fs) {
buff = fgets(buff, len, (FILE*)fil->obj.fs); buff = fgets(buff, len, (FILE*)fil->obj.fs);
if (buff != NULL) { if (buff != nullptr) {
fil->fptr = *buff; fil->fptr = *buff;
} }
// TRACE_SIMPGMSPACE("fgets(%p) %u, %s", fil->obj.fs, len, buff); // TRACE_SIMPGMSPACE("fgets(%p) %u, %s", fil->obj.fs, len, buff);
@ -396,7 +396,7 @@ FRESULT f_close (FIL * fil)
TRACE_SIMPGMSPACE("f_close(%p) (FIL:%p)", fil->obj.fs, fil); TRACE_SIMPGMSPACE("f_close(%p) (FIL:%p)", fil->obj.fs, fil);
if (fil->obj.fs) { if (fil->obj.fs) {
fclose((FILE*)fil->obj.fs); fclose((FILE*)fil->obj.fs);
fil->obj.fs = NULL; fil->obj.fs = nullptr;
} }
return FR_OK; return FR_OK;
} }
@ -516,7 +516,7 @@ FRESULT f_rename(const TCHAR *oldname, const TCHAR *newname)
FRESULT f_utime(const TCHAR* path, const FILINFO* fno) FRESULT f_utime(const TCHAR* path, const FILINFO* fno)
{ {
if (fno == NULL) if (fno == nullptr)
return FR_INVALID_PARAMETER; return FR_INVALID_PARAMETER;
std::string simpath = convertToSimuPath(path); std::string simpath = convertToSimuPath(path);

View file

@ -1013,7 +1013,7 @@ void sdDone()
{ {
if (sdMounted()) { if (sdMounted()) {
audioQueue.stopSD(); audioQueue.stopSD();
f_mount(NULL, "", 0); // unmount SD f_mount(nullptr, "", 0); // unmount SD
} }
} }

View file

@ -171,7 +171,7 @@ void usbMassStorage()
Card_state = SD_ST_DATA; Card_state = SD_ST_DATA;
audioQueue.stopSD(); audioQueue.stopSD();
logsClose(); logsClose();
f_mount(NULL, "", 0); // unmount SD f_mount(nullptr, "", 0); // unmount SD
} }
if (!initialized) { if (!initialized) {

View file

@ -138,14 +138,12 @@ static void processMultiTelemetryPaket(const uint8_t *packet)
TRACE("[MP] Received Frsky HUB telemetry len %d < 4", len); TRACE("[MP] Received Frsky HUB telemetry len %d < 4", len);
break; break;
#if defined(MULTI_SPORT)
case FrSkySportTelemtry: case FrSkySportTelemtry:
if (len >= 4) if (len >= 4)
sportProcessTelemetryPacket(data); sportProcessTelemetryPacket(data);
else else
TRACE("[MP] Received sport telemetry len %d < 4", len); TRACE("[MP] Received sport telemetry len %d < 4", len);
break; break;
#endif
case InputSync: case InputSync:
if (len >= 6) if (len >= 6)
@ -158,7 +156,7 @@ static void processMultiTelemetryPaket(const uint8_t *packet)
// Just an ack to our command, ignore for now // Just an ack to our command, ignore for now
break; break;
#if defined(MULTI_SPORT) && defined(LUA) #if defined(LUA)
case FrskySportPolling: case FrskySportPolling:
if (len >= 1 && outputTelemetryBuffer.destination == TELEMETRY_ENDPOINT_SPORT && data[0] == outputTelemetryBuffer.sport.physicalId) { if (len >= 1 && outputTelemetryBuffer.destination == TELEMETRY_ENDPOINT_SPORT && data[0] == outputTelemetryBuffer.sport.physicalId) {
TRACE("MP Sending sport data out."); TRACE("MP Sending sport data out.");

View file

@ -137,7 +137,7 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
LUA_API const lua_Number *lua_version (lua_State *L) { LUA_API const lua_Number *lua_version (lua_State *L) {
static const lua_Number version = LUA_VERSION_NUM; static const lua_Number version = LUA_VERSION_NUM;
if (L == NULL) return &version; if (L == nullptr) return &version;
else return G(L)->version; else return G(L)->version;
} }
@ -392,15 +392,15 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
if (!ttisstring(o)) { if (!ttisstring(o)) {
lua_lock(L); /* `luaV_tostring' may create a new string */ lua_lock(L); /* `luaV_tostring' may create a new string */
if (!luaV_tostring(L, o)) { /* conversion failed? */ if (!luaV_tostring(L, o)) { /* conversion failed? */
if (len != NULL) *len = 0; if (len != nullptr) *len = 0;
lua_unlock(L); lua_unlock(L);
return NULL; return nullptr;
} }
luaC_checkGC(L); luaC_checkGC(L);
o = index2addr(L, idx); /* previous call may reallocate the stack */ o = index2addr(L, idx); /* previous call may reallocate the stack */
lua_unlock(L); lua_unlock(L);
} }
if (len != NULL) *len = tsvalue(o)->len; if (len != nullptr) *len = tsvalue(o)->len;
return svalue(o); return svalue(o);
} }
@ -421,7 +421,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
if (ttislcf(o)) return lcfvalue(o); if (ttislcf(o)) return lcfvalue(o);
else if (ttisCclosure(o)) else if (ttisCclosure(o))
return clCvalue(o)->f; return clCvalue(o)->f;
else return NULL; /* not a C function */ else return nullptr; /* not a C function */
} }

View file

@ -142,7 +142,7 @@ static const luaL_Reg co_funcs[] = {
{"status", luaB_costatus}, {"status", luaB_costatus},
{"wrap", luaB_cowrap}, {"wrap", luaB_cowrap},
{"yield", luaB_yield}, {"yield", luaB_yield},
{NULL, NULL} {nullptr, nullptr}
}; };

View file

@ -160,7 +160,7 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
ls->current = firstchar; ls->current = firstchar;
ls->lookahead.token = TK_EOS; /* no look-ahead token */ ls->lookahead.token = TK_EOS; /* no look-ahead token */
ls->z = z; ls->z = z;
ls->fs = NULL; ls->fs = nullptr;
ls->linenumber = 1; ls->linenumber = 1;
ls->lastline = 1; ls->lastline = 1;
ls->source = source; ls->source = source;
@ -416,7 +416,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
int sep = skip_sep(ls); int sep = skip_sep(ls);
luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
if (sep >= 0) { if (sep >= 0) {
read_long_string(ls, NULL, sep); /* skip long comment */ read_long_string(ls, nullptr, sep); /* skip long comment */
luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */
break; break;
} }

View file

@ -86,65 +86,53 @@ def main():
maxsize = 65536 * 4 maxsize = 65536 * 4
elif board_name == "x9lite": elif board_name == "x9lite":
cmake_options["PCB"] = "X9LITE" cmake_options["PCB"] = "X9LITE"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9lite firmware_options = options_taranis_x9lite
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "x7": elif board_name == "x7":
cmake_options["PCB"] = "X7" cmake_options["PCB"] = "X7"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp firmware_options = options_taranis_x9dp
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "xlite": elif board_name == "xlite":
cmake_options["PCB"] = "XLITE" cmake_options["PCB"] = "XLITE"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_xlite firmware_options = options_taranis_xlite
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "xlites": elif board_name == "xlites":
cmake_options["PCB"] = "XLITES" cmake_options["PCB"] = "XLITES"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_xlites firmware_options = options_taranis_xlites
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "x9d": elif board_name == "x9d":
cmake_options["PCB"] = "X9D" cmake_options["PCB"] = "X9D"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9d firmware_options = options_taranis_x9d
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "x9d+": elif board_name == "x9d+":
cmake_options["PCB"] = "X9D+" cmake_options["PCB"] = "X9D+"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp firmware_options = options_taranis_x9dp
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "x9d+2019": elif board_name == "x9d+2019":
cmake_options["PCB"] = "X9D+" cmake_options["PCB"] = "X9D+"
cmake_options["PCBREV"] = "2019" cmake_options["PCBREV"] = "2019"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp firmware_options = options_taranis_x9dp
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "x9e": elif board_name == "x9e":
cmake_options["PCB"] = "X9E" cmake_options["PCB"] = "X9E"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9e firmware_options = options_taranis_x9e
maxsize = 65536 * 8 maxsize = 65536 * 8
elif board_name == "x10": elif board_name == "x10":
cmake_options["PCB"] = "X10" cmake_options["PCB"] = "X10"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x10 firmware_options = options_horus_x10
maxsize = 2 * 1024 * 1024 maxsize = 2 * 1024 * 1024
elif board_name == "x10express": elif board_name == "x10express":
cmake_options["PCB"] = "X10" cmake_options["PCB"] = "X10"
cmake_options["PCBREV"] = "EXPRESS" cmake_options["PCBREV"] = "EXPRESS"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x10 firmware_options = options_horus_x10
maxsize = 2 * 1024 * 1024 maxsize = 2 * 1024 * 1024
elif board_name == "x12s": elif board_name == "x12s":
cmake_options["PCB"] = "X12S" cmake_options["PCB"] = "X12S"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x12s firmware_options = options_horus_x12s
maxsize = 2 * 1024 * 1024 maxsize = 2 * 1024 * 1024
elif board_name == "t12": elif board_name == "t12":
cmake_options["PCB"] = "X7" cmake_options["PCB"] = "X7"
cmake_options["PCBREV"] = "T12" cmake_options["PCBREV"] = "T12"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp firmware_options = options_taranis_x9dp
maxsize = 65536 * 8 maxsize = 65536 * 8
else: else: