From 2c47883cc22693444a3741a64bab2786f7491be5 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 5 Aug 2018 19:33:28 +0200 Subject: [PATCH] Companion GCC8 warnings removed --- companion/src/firmwares/customfunctiondata.cpp | 2 +- companion/src/firmwares/generalsettings.cpp | 18 +++++++++--------- companion/src/firmwares/generalsettings.h | 4 ++-- companion/src/firmwares/io_data.cpp | 4 ++-- companion/src/firmwares/io_data.h | 6 +++--- companion/src/firmwares/modeldata.cpp | 4 ++-- companion/src/firmwares/modeldata.h | 4 ++-- companion/src/firmwares/telem_data.cpp | 2 +- companion/src/firmwares/telem_data.h | 2 +- companion/src/modeledit/mixes.cpp | 4 ++-- companion/src/modeledit/telemetry.cpp | 2 +- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/companion/src/firmwares/customfunctiondata.cpp b/companion/src/firmwares/customfunctiondata.cpp index 66a38db0e..882d115cd 100644 --- a/companion/src/firmwares/customfunctiondata.cpp +++ b/companion/src/firmwares/customfunctiondata.cpp @@ -26,7 +26,7 @@ void CustomFunctionData::clear() { - memset(this, 0, sizeof(CustomFunctionData)); + memset(reinterpret_cast(this), 0, sizeof(CustomFunctionData)); if (!getCurrentFirmware()->getCapability(SafetyChannelCustomFunction)) { func = FuncTrainer; } diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index bc89b7dea..93035f9f6 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -306,31 +306,31 @@ void GeneralSettings::convert(RadioDataConversionState & cstate) // SE and SG are skipped on X7 board if (IS_TARANIS_X7(cstate.toType)) { if (IS_TARANIS_X9(cstate.fromType) || IS_HORUS(cstate.fromType)) { - strncpy(switchName[4], switchName[5], sizeof(switchName[0])); - strncpy(switchName[5], switchName[7], sizeof(switchName[0])); + strncpy(switchName[4], switchName[5], sizeof(switchName[4])); + strncpy(switchName[5], switchName[7], sizeof(switchName[5])); } } else if (IS_TARANIS_X7(cstate.fromType)) { if (IS_TARANIS_X9(cstate.toType) || IS_HORUS(cstate.toType)) { - strncpy(switchName[5], switchName[4], sizeof(switchName[0])); - strncpy(switchName[7], switchName[5], sizeof(switchName[0])); + strncpy(switchName[5], switchName[4], sizeof(switchName[5])); + strncpy(switchName[7], switchName[5], sizeof(switchName[7])); } } // LS and RS sliders are after 2 aux sliders on X12 and X9E if ((IS_HORUS_X12S(cstate.toType) || IS_TARANIS_X9E(cstate.toType)) && !IS_HORUS_X12S(cstate.fromType) && !IS_TARANIS_X9E(cstate.fromType)) { strncpy(sliderName[0], sliderName[2], sizeof(sliderName[0])); - strncpy(sliderName[1], sliderName[3], sizeof(sliderName[0])); + strncpy(sliderName[1], sliderName[3], sizeof(sliderName[1])); } else if (!IS_TARANIS_X9E(cstate.toType) && !IS_HORUS_X12S(cstate.toType) && (IS_HORUS_X12S(cstate.fromType) || IS_TARANIS_X9E(cstate.fromType))) { - strncpy(sliderName[2], sliderName[0], sizeof(sliderName[0])); - strncpy(sliderName[3], sliderName[1], sizeof(sliderName[0])); + strncpy(sliderName[2], sliderName[0], sizeof(sliderName[2])); + strncpy(sliderName[3], sliderName[1], sizeof(sliderName[3])); } if (IS_HORUS(cstate.toType)) { // 6P switch is only on Horus (by default) if (cstate.fromBoard.getCapability(Board::FactoryInstalledPots) == 2) { - strncpy(potName[2], potName[1], sizeof(potName[0])); + strncpy(potName[2], potName[1], sizeof(potName[2])); potName[1][0] = '\0'; } } @@ -338,7 +338,7 @@ void GeneralSettings::convert(RadioDataConversionState & cstate) if (IS_TARANIS(cstate.toType)) { // No S3 pot on Taranis boards by default if (cstate.fromBoard.getCapability(Board::FactoryInstalledPots) > 2) - strncpy(potName[1], potName[2], sizeof(potName[0])); + strncpy(potName[1], potName[2], sizeof(potName[1])); contrast = qBound(getCurrentFirmware()->getCapability(MinContrast), contrast, getCurrentFirmware()->getCapability(MaxContrast)); } diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 436b684b0..aa11b6709 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -48,7 +48,7 @@ class TrainerMix { RawSwitch swtch; int weight; unsigned int mode; // off, add-mode, subst-mode - void clear() { memset(this, 0, sizeof(TrainerMix)); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(TrainerMix)); } }; class TrainerData { @@ -56,7 +56,7 @@ class TrainerData { TrainerData() { clear(); } int calib[4]; TrainerMix mix[4]; - void clear() { memset(this, 0, sizeof(TrainerData)); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(TrainerData)); } }; class GeneralSettings { diff --git a/companion/src/firmwares/io_data.cpp b/companion/src/firmwares/io_data.cpp index 180018091..f7df7ddf6 100644 --- a/companion/src/firmwares/io_data.cpp +++ b/companion/src/firmwares/io_data.cpp @@ -80,7 +80,7 @@ QString LimitData::offsetToString() const void LimitData::clear() { - memset(this, 0, sizeof(LimitData)); + memset(reinterpret_cast(this), 0, sizeof(LimitData)); min = -1000; max = +1000; } @@ -123,7 +123,7 @@ QString CurveData::nameToString(const int idx) const void FlightModeData::clear(const int phase) { - memset(this, 0, sizeof(FlightModeData)); + memset(reinterpret_cast(this), 0, sizeof(FlightModeData)); if (phase != 0) { for (int idx=0; idx(this), 0, sizeof(ExpoData)); } void convert(RadioDataConversionState & cstate); }; @@ -89,7 +89,7 @@ class MixData { int sOffset; char name[MIXDATA_NAME_LEN+1]; - void clear() { memset(this, 0, sizeof(MixData)); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(MixData)); } }; class LimitData { @@ -173,7 +173,7 @@ class SwashRingData { RawSource aileronSource; RawSource elevatorSource; unsigned int value; - void clear() { memset(this, 0, sizeof(SwashRingData)); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(SwashRingData)); } }; #endif // IO_DATA_H diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index c2c69ee16..52b786e62 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -83,7 +83,7 @@ ModelData::ModelData(const ModelData & src) ModelData & ModelData::operator = (const ModelData & src) { - memcpy(this, &src, sizeof(ModelData)); + memcpy(reinterpret_cast(this), &src, sizeof(ModelData)); return *this; } @@ -184,7 +184,7 @@ void ModelData::clearMixes() void ModelData::clear() { - memset(this, 0, sizeof(ModelData)); + memset(reinterpret_cast(this), 0, sizeof(ModelData)); modelIndex = -1; // an invalid index, this is managed by the TreeView data model moduleData[0].channelsCount = 8; moduleData[1].channelsStart = 0; diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index ee3e4eb5f..a5e53432c 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -74,7 +74,7 @@ class TimerData { unsigned int val; unsigned int persistent; int pvalue; - void clear() { memset(this, 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); } void convert(RadioDataConversionState & cstate); }; @@ -86,7 +86,7 @@ class ScriptData { char filename[10+1]; char name[10+1]; int inputs[CPN_MAX_SCRIPT_INPUTS]; - void clear() { memset(this, 0, sizeof(ScriptData)); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(ScriptData)); } }; /* diff --git a/companion/src/firmwares/telem_data.cpp b/companion/src/firmwares/telem_data.cpp index 3890f5bb2..af31f3b38 100644 --- a/companion/src/firmwares/telem_data.cpp +++ b/companion/src/firmwares/telem_data.cpp @@ -47,7 +47,7 @@ RawSourceRange FrSkyChannelData::getRange() const void FrSkyScreenData::clear() { - memset(this, 0, sizeof(FrSkyScreenData)); + memset(reinterpret_cast(this), 0, sizeof(FrSkyScreenData)); if (!IS_ARM(getCurrentBoard())) { type = TELEMETRY_SCREEN_NUMBERS; } diff --git a/companion/src/firmwares/telem_data.h b/companion/src/firmwares/telem_data.h index 9b98cc7ba..74a4600a2 100644 --- a/companion/src/firmwares/telem_data.h +++ b/companion/src/firmwares/telem_data.h @@ -64,7 +64,7 @@ class FrSkyChannelData { float getRatio() const; RawSourceRange getRange() const; - void clear() { memset(this, 0, sizeof(FrSkyChannelData)); } + void clear() { memset(reinterpret_cast(this), 0, sizeof(FrSkyChannelData)); } static QString unitString(int units) { diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index ef9611239..f5d76d32f 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -155,7 +155,7 @@ bool MixesPanel::gm_insertMix(int idx) int i = model->mixData[idx].destCh; memmove(&model->mixData[idx+1], &model->mixData[idx], (firmware->getCapability(Mixes)-(idx+1)) * sizeof(MixData) ); - memset(&model->mixData[idx], 0, sizeof(MixData)); + memset(reinterpret_cast(&model->mixData[idx]), 0, sizeof(MixData)); model->mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE); model->mixData[idx].destCh = i; model->mixData[idx].weight = 100; @@ -166,7 +166,7 @@ void MixesPanel::gm_deleteMix(int index) { memmove(&model->mixData[index], &model->mixData[index+1], (firmware->getCapability(Mixes)-(index+1)) * sizeof(MixData)); - memset(&model->mixData[firmware->getCapability(Mixes)-1], 0, sizeof(MixData)); + memset(reinterpret_cast(&model->mixData[firmware->getCapability(Mixes)-1]), 0, sizeof(MixData)); } void MixesPanel::gm_openMix(int index) diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 043437f18..dd578a37c 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -498,7 +498,7 @@ void TelemetryCustomScreen::updateBar(int line) void TelemetryCustomScreen::on_screenType_currentIndexChanged(int index) { if (!lock) { - memset(&screen.body, 0, sizeof(screen.body)); + memset(reinterpret_cast(&screen.body), 0, sizeof(screen.body)); update(); emit modified(); }