From e7736f3fdc1729a0608d86827ec4679ff9c799e1 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 28 Aug 2019 10:28:11 +0200 Subject: [PATCH] Replace NULL by nullptr --- radio/src/bin_allocator.cpp | 2 +- radio/src/bluetooth.cpp | 2 +- radio/src/cli.cpp | 12 +++++----- radio/src/gui/128x64/model_custom_scripts.cpp | 2 +- radio/src/gui/128x64/radio_setup.cpp | 2 +- radio/src/gui/128x64/view_main.cpp | 2 +- radio/src/gui/212x64/model_setup.cpp | 2 +- .../gui/212x64/model_special_functions.cpp | 2 +- radio/src/gui/212x64/radio_setup.cpp | 2 +- radio/src/gui/212x64/widgets.cpp | 2 +- radio/src/lua/interface.cpp | 24 +++++++++---------- radio/src/opentx.cpp | 2 +- radio/src/opentx.h | 2 +- radio/src/sdcard.cpp | 24 +++++++++---------- radio/src/targets/common/arm/CMakeLists.txt | 5 ---- radio/src/targets/horus/audio_spi_driver.cpp | 6 ++--- radio/src/targets/horus/diskio.cpp | 2 +- radio/src/targets/simu/opentxsimulator.cpp | 4 ++-- radio/src/targets/simu/opentxsimulator.h | 2 +- radio/src/targets/simu/simpgmspace.cpp | 8 +++---- radio/src/targets/simu/simufatfs.cpp | 6 ++--- radio/src/targets/sky9x/diskio.cpp | 2 +- radio/src/targets/sky9x/massstorage.cpp | 2 +- radio/src/telemetry/multi.cpp | 4 +--- radio/src/thirdparty/Lua/src/lapi.c | 10 ++++---- radio/src/thirdparty/Lua/src/lcorolib.c | 2 +- radio/src/thirdparty/Lua/src/llex.c | 4 ++-- radio/util/build-firmware.py | 12 ---------- 28 files changed, 66 insertions(+), 85 deletions(-) diff --git a/radio/src/bin_allocator.cpp b/radio/src/bin_allocator.cpp index 7ed3c3086..8d1bfd477 100644 --- a/radio/src/bin_allocator.cpp +++ b/radio/src/bin_allocator.cpp @@ -97,7 +97,7 @@ void *bin_l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) free(ptr); } } - return NULL; + return nullptr; } else { #if defined(DEBUG) diff --git a/radio/src/bluetooth.cpp b/radio/src/bluetooth.cpp index db02e6e54..877d7466b 100644 --- a/radio/src/bluetooth.cpp +++ b/radio/src/bluetooth.cpp @@ -95,7 +95,7 @@ char * Bluetooth::readline(bool error_reset) state = BLUETOOTH_STATE_OFF; wakeupTime = get_tmr10ms() + 100; /* 1s */ #endif - return NULL; + return nullptr; } else #endif diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index 7aa071190..cb72b8076 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -70,7 +70,7 @@ int toLongLongInt(const char ** argv, int index, long long int * val) base = 16; s = &argv[index][2]; } - char * endptr = NULL; + char * endptr = nullptr; *val = strtoll(s, &endptr, base); if (*endptr == '\0') return 1; @@ -782,7 +782,7 @@ const MemArea memAreas[] = { { "USART1", USART1, sizeof(USART_TypeDef) }, { "USART2", USART2, sizeof(USART_TypeDef) }, { "USART3", USART3, sizeof(USART_TypeDef) }, - { NULL, NULL, 0 }, + { nullptr, nullptr, 0 }, }; int cliSet(const char ** argv) @@ -947,7 +947,7 @@ int cliDisplay(const char ** argv) { 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])) { dump((uint8_t *)area->start, area->size); return 0; @@ -1218,12 +1218,12 @@ const CliCommand cliCommands[] = { #if defined(BLUETOOTH) { "bt", cliBlueTooth, "|" }, #endif - { NULL, NULL, NULL } /* sentinel */ + { nullptr, nullptr, nullptr } /* sentinel */ }; 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])) { serialPrint("%s %s", command->name, command->args); if (argv[1][0] != '\0') { @@ -1242,7 +1242,7 @@ int cliExecCommand(const char ** argv) if (argv[0][0] == '\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])) { return command->func(argv); } diff --git a/radio/src/gui/128x64/model_custom_scripts.cpp b/radio/src/gui/128x64/model_custom_scripts.cpp index 4ff56e735..332d09fa4 100644 --- a/radio/src/gui/128x64/model_custom_scripts.cpp +++ b/radio/src/gui/128x64/model_custom_scripts.cpp @@ -33,7 +33,7 @@ void onModelCustomScriptMenu(const char *result) ScriptData &sd = g_model.scriptsData[s_currIdx]; 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); } } diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index ec9207dac..aabf4dc5e 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -31,7 +31,7 @@ const unsigned char sticks[] = { #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ 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) diff --git a/radio/src/gui/128x64/view_main.cpp b/radio/src/gui/128x64/view_main.cpp index 9510b38b1..a54c00fa6 100644 --- a/radio/src/gui/128x64/view_main.cpp +++ b/radio/src/gui/128x64/view_main.cpp @@ -550,7 +550,7 @@ void menuMainView(event_t event) lcdDrawText(lcdLastRightPos, 5*FH, "%", BOLD); } lcdDrawText(lcdLastRightPos, 5*FH, "]", BOLD); - warningText = NULL; + warningText = nullptr; } #endif diff --git a/radio/src/gui/212x64/model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp index 0372092fc..8b933dfbb 100644 --- a/radio/src/gui/212x64/model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -143,7 +143,7 @@ void copySelection(char * dst, const char * src, uint8_t size) void onModelSetupBitmapMenu(const char * result) { 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); } } diff --git a/radio/src/gui/212x64/model_special_functions.cpp b/radio/src/gui/212x64/model_special_functions.cpp index 2f382e45e..653e83783 100644 --- a/radio/src/gui/212x64/model_special_functions.cpp +++ b/radio/src/gui/212x64/model_special_functions.cpp @@ -52,7 +52,7 @@ void onCustomFunctionsFileSelectionMenu(const char * result) strcpy(directory, SOUNDS_PATH); 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); } } diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index 1deb944e1..929cfe944 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -33,7 +33,7 @@ const unsigned char sticks[] = { #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ 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) diff --git a/radio/src/gui/212x64/widgets.cpp b/radio/src/gui/212x64/widgets.cpp index 424b9aade..fcb0c352d 100644 --- a/radio/src/gui/212x64/widgets.cpp +++ b/radio/src/gui/212x64/widgets.cpp @@ -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 ) { 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) diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 104b4068a..4661b4c05 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -36,7 +36,7 @@ extern "C" { #define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100) #define LUA_WARNING_INFO_LEN 64 -lua_State *lsScripts = NULL; +lua_State *lsScripts = nullptr; uint8_t luaState = 0; uint8_t luaScriptsCount = 0; ScriptInternalData scriptInternalData[MAX_SCRIPTS]; @@ -256,7 +256,7 @@ void luaClose(lua_State ** L) if (*L == lsScripts) luaDisable(); } 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); lua_unlock(L); if (f_close(&D) == FR_OK) { - if (finfo != NULL) + if (finfo != nullptr) f_utime(filename, finfo); // set the file mod time 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) { return SCRIPT_PANIC; - } else if (filename == NULL) { + } else if (filename == nullptr) { return SCRIPT_NOFILE; } @@ -412,7 +412,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * char lmode[6] = "bt"; uint8_t ret = SCRIPT_NOFILE; - if (mode != NULL) { + if (mode != nullptr) { strncpy(lmode, mode, sizeof(lmode)-1); lmode[sizeof(lmode)-1] = '\0'; } @@ -432,7 +432,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * fnamelen = strlen(filename); // 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; if (fnamelen > sizeof(filenameFull) - sizeof(SCRIPT_BIN_EXT)) { 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); // we don't pass 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) // 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")) { @@ -515,7 +515,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * scriptNeedsCompile = true; 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); - lstatus = luaL_loadfilex(L, filenameFull, NULL); + lstatus = luaL_loadfilex(L, filenameFull, nullptr); } if (lstatus == LUA_OK) { if (scriptNeedsCompile && loadFileType == 1) { @@ -545,7 +545,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char * 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 lstatus = 0; @@ -910,7 +910,7 @@ bool luaDoOneRunPermanentScript(event_t evt, int i, uint32_t scriptType) #if defined(SIMU) || defined(DEBUG) const char *filename; #endif - ScriptInputsOutputs * sio = NULL; + ScriptInputsOutputs * sio = nullptr; #if SCRIPT_MIX_FIRST > 0 if ((scriptType & RUN_MIX_SCRIPT) && (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST)) { #else @@ -1082,13 +1082,13 @@ void luaInit() if (luaState != INTERPRETER_PANIC) { #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) memset(&lsScriptsTrace, 0 , sizeof(lsScriptsTrace)); lsScriptsTrace.script = "lua_newstate(scripts)"; lsScripts = lua_newstate(tracer_alloc, &lsScriptsTrace); //we use tracer allocator #else - lsScripts = lua_newstate(l_alloc, NULL); //we use Lua default allocator + lsScripts = lua_newstate(l_alloc, nullptr); //we use Lua default allocator #endif if (lsScripts) { // install our panic handler diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index d80ec7668..dff7480a5 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -2048,7 +2048,7 @@ uint32_t pwrPressedDuration() uint32_t pwrCheck() { - const char * message = NULL; + const char * message = nullptr; enum PwrCheckState { PWR_CHECK_ON, diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 3dad381f1..984cf05f8 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1210,7 +1210,7 @@ extern union ReusableBuffer reusableBuffer; uint8_t zlen(const char *str, uint8_t size); bool zexist(const char *str, uint8_t 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) #if defined(EEPROM) #define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1) diff --git a/radio/src/sdcard.cpp b/radio/src/sdcard.cpp index 60948c913..56705b633 100644 --- a/radio/src/sdcard.cpp +++ b/radio/src/sdcard.cpp @@ -68,7 +68,7 @@ const char * sdCheckAndCreateDirectory(const char * path) f_closedir(&archiveFolder); } - return NULL; + return nullptr; } 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). @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; 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, "/"); strncat(fqfp + (++fplen), file, _MAX_LFN); - if (pattern == NULL) { + if (pattern == nullptr) { // no extensions list, just check the filename as-is return isFileAvailable(fqfp, exclDir); } @@ -129,13 +129,13 @@ bool isFilePatternAvailable(const char * path, const char * file, const char * p while (plen > 0 && ext) { strncat(fqfp + len, ext, extlen); if (isFileAvailable(fqfp, exclDir)) { - if (match != NULL) strncat(&(match[0]='\0'), ext, extlen); + if (match != nullptr) strncat(&(match[0]='\0'), ext, extlen); return true; } plen -= extlen; if (plen > 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; char * pos = (char *)getFileExtension(filename); if (!pos || pos == filename) - return NULL; + return nullptr; int multiplier = 1; while (pos > filename) { pos--; @@ -179,7 +179,7 @@ int findNextFileIndex(char * filename, uint8_t size, const char * directory) uint8_t extlen; char * indexPos = getFileIndex(filename, index); 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); while (1) { index++; @@ -188,7 +188,7 @@ int findNextFileIndex(char * filename, uint8_t size, const char * directory) } char * pos = strAppendUnsigned(indexPos, index); strAppend(pos, extension); - if (!isFilePatternAvailable(directory, filename, NULL, false)) { + if (!isFilePatternAvailable(directory, filename, nullptr, false)) { return index; } } @@ -249,12 +249,12 @@ bool isExtensionMatching(const char * extension, const char * pattern, char * ma plen = (int)fnlen; while (plen > 0 && ext) { 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; } plen -= extlen; if (plen > 0) { - ext = getFileExtension(pattern, plen, 0, NULL, &extlen); + ext = getFileExtension(pattern, plen, 0, nullptr, &extlen); } } return false; @@ -275,7 +275,7 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen if (selection) { 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 { flags = s_last_flags; @@ -475,7 +475,7 @@ const char * sdCopyFile(const char * srcPath, const char * destPath) return SDCARD_ERROR(result); } - return NULL; + return nullptr; } const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir) diff --git a/radio/src/targets/common/arm/CMakeLists.txt b/radio/src/targets/common/arm/CMakeLists.txt index f47c72760..d07988221 100644 --- a/radio/src/targets/common/arm/CMakeLists.txt +++ b/radio/src/targets/common/arm/CMakeLists.txt @@ -14,7 +14,6 @@ option(DSM2 "DSM2 TX Module" ON) option(SBUS "SBUS 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(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(DEBUG_INTERRUPTS "Count interrupts" 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) endif() -if(MULTI_SPORT) - add_definitions(-DMULTI_SPORT) -endif() - if(CROSSFIRE) add_definitions(-DCROSSFIRE) set(PULSES_SRC diff --git a/radio/src/targets/horus/audio_spi_driver.cpp b/radio/src/targets/horus/audio_spi_driver.cpp index 430090bb8..dc05ef06d 100644 --- a/radio/src/targets/horus/audio_spi_driver.cpp +++ b/radio/src/targets/horus/audio_spi_driver.cpp @@ -378,7 +378,7 @@ void audioInit() audioSendRiffHeader(); } -uint8_t * currentBuffer = NULL; +uint8_t * currentBuffer = nullptr; uint32_t currentSize = 0; int16_t newVolume = -1; @@ -389,7 +389,7 @@ void audioSetCurrentBuffer(const AudioBuffer * buffer) currentSize = buffer->size * 2; } else { - currentBuffer = NULL; + currentBuffer = nullptr; currentSize = 0; } } @@ -413,7 +413,7 @@ void audioConsumeCurrentBuffer() currentSize -= written; if (currentSize == 0) { audioQueue.buffersFifo.freeNextFilledBuffer(); - currentBuffer = NULL; + currentBuffer = nullptr; currentSize = 0; } } diff --git a/radio/src/targets/horus/diskio.cpp b/radio/src/targets/horus/diskio.cpp index 9572fc796..b9bcda011 100644 --- a/radio/src/targets/horus/diskio.cpp +++ b/radio/src/targets/horus/diskio.cpp @@ -365,7 +365,7 @@ void sdDone() #if defined(LOG_TELEMETRY) f_close(&g_telemetryFile); #endif - f_mount(NULL, "", 0); // unmount SD + f_mount(nullptr, "", 0); // unmount SD } } #endif diff --git a/radio/src/targets/simu/opentxsimulator.cpp b/radio/src/targets/simu/opentxsimulator.cpp index bfdaae1fd..1864e0d7b 100644 --- a/radio/src/targets/simu/opentxsimulator.cpp +++ b/radio/src/targets/simu/opentxsimulator.cpp @@ -52,7 +52,7 @@ void firmwareTraceCb(const char * text) OpenTxSimulator::OpenTxSimulator() : SimulatorInterface(), - m_timer10ms(NULL), + m_timer10ms(nullptr), m_resetOutputsData(true), m_stopRequested(false) { @@ -62,7 +62,7 @@ OpenTxSimulator::OpenTxSimulator() : OpenTxSimulator::~OpenTxSimulator() { - traceCallback = NULL; + traceCallback = nullptr; tracebackDevices.clear(); if (m_timer10ms) diff --git a/radio/src/targets/simu/opentxsimulator.h b/radio/src/targets/simu/opentxsimulator.h index e38f2bdfb..7369a56c3 100644 --- a/radio/src/targets/simu/opentxsimulator.h +++ b/radio/src/targets/simu/opentxsimulator.h @@ -51,7 +51,7 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface public slots: 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 setSdPath(const QString & sdPath = "", const QString & settingsPath = ""); virtual void setVolumeGain(const int value); diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 68d6b95d1..fb3d11a66 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -220,8 +220,8 @@ void StopSimu() simu_shutdown = true; - pthread_join(mixerTaskId, NULL); - pthread_join(menusTaskId, NULL); + pthread_join(mixerTaskId, nullptr); + pthread_join(menusTaskId, nullptr); simu_running = false; } @@ -348,7 +348,7 @@ void * audioThread(void *) wanted.channels = 1; /* 1 = mono, 2 = stereo */ wanted.samples = AUDIO_BUFFER_SIZE*2; /* Good low-latency value for callback */ wanted.callback = fillAudioBuffer; - wanted.userdata = NULL; + wanted.userdata = nullptr; /* SDL_OpenAudio() internally calls SDL_InitSubSystem(SDL_INIT_AUDIO), @@ -390,7 +390,7 @@ void StartAudioThread(int volumeGain) void StopAudioThread() { simuAudio.threadRunning = false; - pthread_join(simuAudio.threadPid, NULL); + pthread_join(simuAudio.threadPid, nullptr); } #endif // #if defined(SIMU_AUDIO) diff --git a/radio/src/targets/simu/simufatfs.cpp b/radio/src/targets/simu/simufatfs.cpp index 4f7e96588..250ab93f2 100644 --- a/radio/src/targets/simu/simufatfs.cpp +++ b/radio/src/targets/simu/simufatfs.cpp @@ -361,7 +361,7 @@ TCHAR * f_gets (TCHAR* buff, int len, FIL* fil) { if (fil && fil->obj.fs) { buff = fgets(buff, len, (FILE*)fil->obj.fs); - if (buff != NULL) { + if (buff != nullptr) { fil->fptr = *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); if (fil->obj.fs) { fclose((FILE*)fil->obj.fs); - fil->obj.fs = NULL; + fil->obj.fs = nullptr; } 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) { - if (fno == NULL) + if (fno == nullptr) return FR_INVALID_PARAMETER; std::string simpath = convertToSimuPath(path); diff --git a/radio/src/targets/sky9x/diskio.cpp b/radio/src/targets/sky9x/diskio.cpp index 394629d70..9a5d06a86 100644 --- a/radio/src/targets/sky9x/diskio.cpp +++ b/radio/src/targets/sky9x/diskio.cpp @@ -1013,7 +1013,7 @@ void sdDone() { if (sdMounted()) { audioQueue.stopSD(); - f_mount(NULL, "", 0); // unmount SD + f_mount(nullptr, "", 0); // unmount SD } } diff --git a/radio/src/targets/sky9x/massstorage.cpp b/radio/src/targets/sky9x/massstorage.cpp index 613bc2a73..b4a7c18a3 100644 --- a/radio/src/targets/sky9x/massstorage.cpp +++ b/radio/src/targets/sky9x/massstorage.cpp @@ -171,7 +171,7 @@ void usbMassStorage() Card_state = SD_ST_DATA; audioQueue.stopSD(); logsClose(); - f_mount(NULL, "", 0); // unmount SD + f_mount(nullptr, "", 0); // unmount SD } if (!initialized) { diff --git a/radio/src/telemetry/multi.cpp b/radio/src/telemetry/multi.cpp index 4f83c58a3..87944a862 100644 --- a/radio/src/telemetry/multi.cpp +++ b/radio/src/telemetry/multi.cpp @@ -138,14 +138,12 @@ static void processMultiTelemetryPaket(const uint8_t *packet) TRACE("[MP] Received Frsky HUB telemetry len %d < 4", len); break; -#if defined(MULTI_SPORT) case FrSkySportTelemtry: if (len >= 4) sportProcessTelemetryPacket(data); else TRACE("[MP] Received sport telemetry len %d < 4", len); break; -#endif case InputSync: if (len >= 6) @@ -158,7 +156,7 @@ static void processMultiTelemetryPaket(const uint8_t *packet) // Just an ack to our command, ignore for now break; -#if defined(MULTI_SPORT) && defined(LUA) +#if defined(LUA) case FrskySportPolling: if (len >= 1 && outputTelemetryBuffer.destination == TELEMETRY_ENDPOINT_SPORT && data[0] == outputTelemetryBuffer.sport.physicalId) { TRACE("MP Sending sport data out."); diff --git a/radio/src/thirdparty/Lua/src/lapi.c b/radio/src/thirdparty/Lua/src/lapi.c index 070b11d62..ec89c99f3 100644 --- a/radio/src/thirdparty/Lua/src/lapi.c +++ b/radio/src/thirdparty/Lua/src/lapi.c @@ -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) { static const lua_Number version = LUA_VERSION_NUM; - if (L == NULL) return &version; + if (L == nullptr) return &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)) { lua_lock(L); /* `luaV_tostring' may create a new string */ if (!luaV_tostring(L, o)) { /* conversion failed? */ - if (len != NULL) *len = 0; + if (len != nullptr) *len = 0; lua_unlock(L); - return NULL; + return nullptr; } luaC_checkGC(L); o = index2addr(L, idx); /* previous call may reallocate the stack */ lua_unlock(L); } - if (len != NULL) *len = tsvalue(o)->len; + if (len != nullptr) *len = tsvalue(o)->len; return svalue(o); } @@ -421,7 +421,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { if (ttislcf(o)) return lcfvalue(o); else if (ttisCclosure(o)) return clCvalue(o)->f; - else return NULL; /* not a C function */ + else return nullptr; /* not a C function */ } diff --git a/radio/src/thirdparty/Lua/src/lcorolib.c b/radio/src/thirdparty/Lua/src/lcorolib.c index e2f601eb6..6bd1e2c19 100644 --- a/radio/src/thirdparty/Lua/src/lcorolib.c +++ b/radio/src/thirdparty/Lua/src/lcorolib.c @@ -142,7 +142,7 @@ static const luaL_Reg co_funcs[] = { {"status", luaB_costatus}, {"wrap", luaB_cowrap}, {"yield", luaB_yield}, - {NULL, NULL} + {nullptr, nullptr} }; diff --git a/radio/src/thirdparty/Lua/src/llex.c b/radio/src/thirdparty/Lua/src/llex.c index 1a32e348b..737cbb9e0 100644 --- a/radio/src/thirdparty/Lua/src/llex.c +++ b/radio/src/thirdparty/Lua/src/llex.c @@ -160,7 +160,7 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, ls->current = firstchar; ls->lookahead.token = TK_EOS; /* no look-ahead token */ ls->z = z; - ls->fs = NULL; + ls->fs = nullptr; ls->linenumber = 1; ls->lastline = 1; ls->source = source; @@ -416,7 +416,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { int sep = skip_sep(ls); luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ 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. */ break; } diff --git a/radio/util/build-firmware.py b/radio/util/build-firmware.py index 6c74ef532..41be5705a 100755 --- a/radio/util/build-firmware.py +++ b/radio/util/build-firmware.py @@ -86,65 +86,53 @@ def main(): maxsize = 65536 * 4 elif board_name == "x9lite": cmake_options["PCB"] = "X9LITE" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9lite maxsize = 65536 * 8 elif board_name == "x7": cmake_options["PCB"] = "X7" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9dp maxsize = 65536 * 8 elif board_name == "xlite": cmake_options["PCB"] = "XLITE" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_xlite maxsize = 65536 * 8 elif board_name == "xlites": cmake_options["PCB"] = "XLITES" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_xlites maxsize = 65536 * 8 elif board_name == "x9d": cmake_options["PCB"] = "X9D" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9d maxsize = 65536 * 8 elif board_name == "x9d+": cmake_options["PCB"] = "X9D+" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9dp maxsize = 65536 * 8 elif board_name == "x9d+2019": cmake_options["PCB"] = "X9D+" cmake_options["PCBREV"] = "2019" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9dp maxsize = 65536 * 8 elif board_name == "x9e": cmake_options["PCB"] = "X9E" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9e maxsize = 65536 * 8 elif board_name == "x10": cmake_options["PCB"] = "X10" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_horus_x10 maxsize = 2 * 1024 * 1024 elif board_name == "x10express": cmake_options["PCB"] = "X10" cmake_options["PCBREV"] = "EXPRESS" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_horus_x10 maxsize = 2 * 1024 * 1024 elif board_name == "x12s": cmake_options["PCB"] = "X12S" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_horus_x12s maxsize = 2 * 1024 * 1024 elif board_name == "t12": cmake_options["PCB"] = "X7" cmake_options["PCBREV"] = "T12" - cmake_options["MULTI_SPORT"] = "ON" firmware_options = options_taranis_x9dp maxsize = 65536 * 8 else: