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

Fix codestyle (#14245)

Fix codestyle and prevent loop when commandLen is zero
This commit is contained in:
Mark Haslinghuis 2025-02-10 15:38:25 +01:00 committed by GitHub
parent 86767ba112
commit 6df8d0edda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -479,7 +479,8 @@ struct ubloxVersion_s ubloxVersionMap[] = {
[UBX_VERSION_M10] = { 0x000A0000, "M10" }, [UBX_VERSION_M10] = { 0x000A0000, "M10" },
}; };
static uint8_t ubloxAddValSet(ubxMessage_t * tx_buffer, ubxValGetSetBytes_e key, const uint8_t * payload, const uint8_t offset) { static uint8_t ubloxAddValSet(ubxMessage_t * tx_buffer, ubxValGetSetBytes_e key, const uint8_t * payload, const uint8_t offset)
{
size_t len; size_t len;
switch((key >> (8 * 3)) & 0xff) { switch((key >> (8 * 3)) & 0xff) {
case 0x10: case 0x10:
@ -498,8 +499,8 @@ static uint8_t ubloxAddValSet(ubxMessage_t * tx_buffer, ubxValGetSetBytes_e key,
default: default:
return 0; return 0;
} }
if (offset + 4 + len > MAX_VALSET_SIZE)
{ if (offset + 4 + len > MAX_VALSET_SIZE) {
return 0; return 0;
} }
@ -538,7 +539,8 @@ static size_t ubloxValGet(ubxMessage_t * tx_buffer, ubxValGetSetBytes_e key, ubl
} }
#endif // not used #endif // not used
static uint8_t ubloxValSet(ubxMessage_t * tx_buffer, ubxValGetSetBytes_e key, uint8_t * payload, ubloxValLayer_e layer) { static uint8_t ubloxValSet(ubxMessage_t * tx_buffer, ubxValGetSetBytes_e key, uint8_t * payload, ubloxValLayer_e layer)
{
memset(&tx_buffer->payload.cfg_valset, 0, sizeof(ubxCfgValSet_t)); memset(&tx_buffer->payload.cfg_valset, 0, sizeof(ubxCfgValSet_t));
// tx_buffer->payload.cfg_valset.version = 0; // tx_buffer->payload.cfg_valset.version = 0;
@ -615,7 +617,8 @@ static void ubloxSendPollMessage(uint8_t msg_id)
ubloxSendMessage(&msg, false); ubloxSendMessage(&msg, false);
} }
static void ubloxSendNAV5Message(uint8_t model) { static void ubloxSendNAV5Message(uint8_t model)
{
DEBUG_SET(DEBUG_GPS_CONNECTION, 0, model); DEBUG_SET(DEBUG_GPS_CONNECTION, 0, model);
ubxMessage_t tx_buffer; ubxMessage_t tx_buffer;
if (gpsData.ubloxM9orAbove) { if (gpsData.ubloxM9orAbove) {
@ -1538,7 +1541,8 @@ static void gpsNewData(uint16_t c)
} }
#ifdef USE_GPS_UBLOX #ifdef USE_GPS_UBLOX
static ubloxVersion_e ubloxParseVersion(const uint32_t version) { static ubloxVersion_e ubloxParseVersion(const uint32_t version)
{
for (size_t i = 0; i < ARRAYLEN(ubloxVersionMap); ++i) { for (size_t i = 0; i < ARRAYLEN(ubloxVersionMap); ++i) {
if (version == ubloxVersionMap[i].hw) { if (version == ubloxVersionMap[i].hw) {
return (ubloxVersion_e) i; return (ubloxVersion_e) i;
@ -2567,8 +2571,7 @@ static void GPS_calculateDistanceFlown(bool initialize)
if (initialize) { if (initialize) {
GPS_distanceFlownInCm = 0; GPS_distanceFlownInCm = 0;
} else { } else if (STATE(GPS_FIX_HOME) && ARMING_FLAG(ARMED)) {
if (STATE(GPS_FIX_HOME) && ARMING_FLAG(ARMED)) {
uint16_t speed = gpsConfig()->gps_use_3d_speed ? gpsSol.speed3d : gpsSol.groundSpeed; uint16_t speed = gpsConfig()->gps_use_3d_speed ? gpsSol.speed3d : gpsSol.groundSpeed;
// Only add up movement when speed is faster than minimum threshold // Only add up movement when speed is faster than minimum threshold
if (speed > GPS_DISTANCE_FLOWN_MIN_SPEED_THRESHOLD_CM_S) { if (speed > GPS_DISTANCE_FLOWN_MIN_SPEED_THRESHOLD_CM_S) {
@ -2577,7 +2580,6 @@ static void GPS_calculateDistanceFlown(bool initialize)
GPS_distanceFlownInCm += dist; GPS_distanceFlownInCm += dist;
} }
} }
}
lastLLH = gpsSol.llh; lastLLH = gpsSol.llh;
} }
@ -2724,4 +2726,3 @@ baudRate_e getGpsPortActualBaudRateIndex(void)
} }
#endif // USE_GPS #endif // USE_GPS