Skip to content

Commit 2152748

Browse files
Merge pull request #11172 from sensei-hacker/fix/cppcheck-critical-bugs
Small C nitpicks from static analysis
2 parents 2257be3 + cdca77e commit 2152748

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/main/fc/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef enum {
6363
FEATURE_PWM_OUTPUT_ENABLE = 1 << 28,
6464
FEATURE_OSD = 1 << 29,
6565
FEATURE_FW_LAUNCH = 1 << 30,
66-
FEATURE_FW_AUTOTRIM = 1 << 31,
66+
FEATURE_FW_AUTOTRIM = 1U << 31,
6767
} features_e;
6868

6969
typedef struct systemConfig_s {

src/main/io/dashboard.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ static const char* const gpsFixTypeText[] = {
172172
"3D"
173173
};
174174

175-
static const char* tickerCharacters = "|/-\\"; // use 2/4/8 characters so that the divide is optimal.
176-
#define TICKER_CHARACTER_COUNT (sizeof(tickerCharacters) / sizeof(char))
175+
static const char tickerCharacters[] = "|/-\\"; // use 2/4/8 characters so that the divide is optimal.
176+
#define TICKER_CHARACTER_COUNT (sizeof(tickerCharacters) - 1)
177177

178178
static timeUs_t nextPageAt;
179179
static bool forcePageChange;

src/main/rx/crsf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ STATIC_UNIT_TESTED void crsfDataReceive(uint16_t c, void *rxCallbackData)
160160
// full frame length includes the length of the address and framelength fields
161161
const int fullFrameLength = crsfFramePosition < 3 ? 5 : crsfFrame.frame.frameLength + CRSF_FRAME_LENGTH_ADDRESS + CRSF_FRAME_LENGTH_FRAMELENGTH;
162162

163+
if (fullFrameLength > CRSF_FRAME_SIZE_MAX) {
164+
crsfFramePosition = 0;
165+
return;
166+
}
167+
163168
if (crsfFramePosition < fullFrameLength) {
164169
crsfFrame.bytes[crsfFramePosition++] = (uint8_t)c;
165170
crsfFrameDone = crsfFramePosition < fullFrameLength ? false : true;

src/main/sensors/temperature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void newSensorCheckAndEnter(uint8_t type, uint64_t addr)
9898

9999
void temperatureInit(void)
100100
{
101-
memset(sensorStatus, 0, sizeof(sensorStatus) * sizeof(*sensorStatus));
101+
memset(sensorStatus, 0, sizeof(sensorStatus));
102102

103103
sensorsSet(SENSOR_TEMP);
104104

0 commit comments

Comments
 (0)