1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00

cppcheck - minor problems fixed (#13609)

This commit is contained in:
Petr Ledvina 2024-04-30 14:04:28 +02:00 committed by GitHub
parent a000913ed4
commit 4640a5da96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 12 additions and 9 deletions

View file

@ -453,6 +453,7 @@ static void cliPrintError(const char *cmdName, const char *format, ...)
va_list va; va_list va;
va_start(va, format); va_start(va, format);
cliPrintErrorVa(cmdName, format, va); cliPrintErrorVa(cmdName, format, va);
va_end(va);
if (!cliWriter) { if (!cliWriter) {
// Supply our own linefeed in case we are printing inside a custom defaults operation // Supply our own linefeed in case we are printing inside a custom defaults operation
@ -467,6 +468,7 @@ static void cliPrintErrorLinef(const char *cmdName, const char *format, ...)
va_list va; va_list va;
va_start(va, format); va_start(va, format);
cliPrintErrorVa(cmdName, format, va); cliPrintErrorVa(cmdName, format, va);
va_end(va);
cliPrintInternal(cliErrorWriter, "\r\n"); cliPrintInternal(cliErrorWriter, "\r\n");
} }

View file

@ -182,7 +182,7 @@ STATIC_UNIT_TESTED void updateLEDDMABuffer(ledStripFormatRGB_e ledFormat, rgbCol
unsigned dmaBufferOffset = 0; unsigned dmaBufferOffset = 0;
for (int index = bits_per_led - 1; index >= 0; index--) { for (int index = bits_per_led - 1; index >= 0; index--) {
ledStripDMABuffer[ledIndex * bits_per_led + dmaBufferOffset++] = (packed_colour & (1 << index)) ? BIT_COMPARE_1 : BIT_COMPARE_0; ledStripDMABuffer[ledIndex * bits_per_led + dmaBufferOffset++] = (packed_colour & (1U << index)) ? BIT_COMPARE_1 : BIT_COMPARE_0;
} }
} }

View file

@ -113,7 +113,7 @@ const adcTagMap_t adcTagMap[] = {
{ DEFIO_TAG_E__NONE, ADC_DEVICE_FOR_INTERNAL, ADC_CHANNEL_VREFINT, 19 }, // 19 VREFINT { DEFIO_TAG_E__NONE, ADC_DEVICE_FOR_INTERNAL, ADC_CHANNEL_VREFINT, 19 }, // 19 VREFINT
{ DEFIO_TAG_E__NONE, ADC_DEVICE_FOR_INTERNAL, ADC_CHANNEL_TEMPSENSOR, 18 }, // 18 VSENSE { DEFIO_TAG_E__NONE, ADC_DEVICE_FOR_INTERNAL, ADC_CHANNEL_TEMPSENSOR, 18 }, // 18 VSENSE
{ DEFIO_TAG_E__NONE, ADC_DEVICE_FOR_INTERNAL, ADC_CHANNEL_VBAT, 17 }, // 17 VBAT/4 { DEFIO_TAG_E__NONE, ADC_DEVICE_FOR_INTERNAL, ADC_CHANNEL_VBAT, 17 }, // 17 VBAT/4
#elif #else
#error MCU not defined #error MCU not defined
#endif #endif

View file

@ -22,7 +22,7 @@
#include "common/time.h" #include "common/time.h"
#define BEEPER_GET_FLAG(mode) (1 << (mode - 1)) #define BEEPER_GET_FLAG(mode) (1 << ((mode) - 1))
#ifdef USE_DSHOT #ifdef USE_DSHOT
#define DSHOT_BEACON_GUARD_DELAY_US 1200000 // Time to separate dshot beacon and armining/disarming events #define DSHOT_BEACON_GUARD_DELAY_US 1200000 // Time to separate dshot beacon and armining/disarming events

View file

@ -579,12 +579,13 @@ void esc4wayProcess(serialPort_t *mspPort)
case cmd_InterfaceSetMode: case cmd_InterfaceSetMode:
{ {
#if defined(USE_SERIAL_4WAY_BLHELI_BOOTLOADER) && defined(USE_SERIAL_4WAY_SK_BOOTLOADER) #if defined(USE_SERIAL_4WAY_BLHELI_BOOTLOADER) && defined(USE_SERIAL_4WAY_SK_BOOTLOADER)
if ((ParamBuf[0] <= imARM_BLB) && (ParamBuf[0] >= imSIL_BLB)) { if ((ParamBuf[0] <= imARM_BLB) && (ParamBuf[0] >= imSIL_BLB))
#elif defined(USE_SERIAL_4WAY_BLHELI_BOOTLOADER) #elif defined(USE_SERIAL_4WAY_BLHELI_BOOTLOADER)
if (((ParamBuf[0] <= imATM_BLB)||(ParamBuf[0] == imARM_BLB)) && (ParamBuf[0] >= imSIL_BLB)) { if (((ParamBuf[0] <= imATM_BLB)||(ParamBuf[0] == imARM_BLB)) && (ParamBuf[0] >= imSIL_BLB))
#elif defined(USE_SERIAL_4WAY_SK_BOOTLOADER) #elif defined(USE_SERIAL_4WAY_SK_BOOTLOADER)
if (ParamBuf[0] == imSK) { if (ParamBuf[0] == imSK)
#endif #endif
{
CurrentInterfaceMode = ParamBuf[0]; CurrentInterfaceMode = ParamBuf[0];
} else { } else {
ACK_OUT = ACK_I_INVALID_PARAM; ACK_OUT = ACK_I_INVALID_PARAM;

View file

@ -153,7 +153,7 @@ void spektrumHandleRSSI(volatile uint8_t spekFrame[])
0,resolution)); 0,resolution));
#else #else
// Do a direkt dBm to percent mapping, keeping the non-linear dBm logarithmic curve. // Do a direkt dBm to percent mapping, keeping the non-linear dBm logarithmic curve.
spekChannelData[rssi_channel] = (uint16_t)(map(rssi), spekChannelData[rssi_channel] = (uint16_t)(map(rssi,
SPEKTRUM_RSSI_MIN, SPEKTRUM_RSSI_MAX, SPEKTRUM_RSSI_MIN, SPEKTRUM_RSSI_MAX,
0,resolution)); 0,resolution));
#endif #endif

View file

@ -226,7 +226,7 @@ bool srxl2ProcessControlData(const Srxl2Header* header, rxRuntimeState_t *rxRunt
DEBUG_PRINTF("vtx region: %x\r\n", vtxData->region); DEBUG_PRINTF("vtx region: %x\r\n", vtxData->region);
// Pack data as it was used before srxl2 to use existing functions. // Pack data as it was used before srxl2 to use existing functions.
// Get the VTX control bytes in a frame // Get the VTX control bytes in a frame
uint32_t vtxControl = (0xE0 << 24) | (0xE0 << 8) | uint32_t vtxControl = (0xE0U << 24) | (0xE0 << 8) |
((vtxData->band & 0x07) << 21) | ((vtxData->band & 0x07) << 21) |
((vtxData->channel & 0x0F) << 16) | ((vtxData->channel & 0x0F) << 16) |
((vtxData->pit & 0x01) << 4) | ((vtxData->pit & 0x01) << 4) |