1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Tidy grab_fields()

This commit is contained in:
AirBreak69 2018-06-14 21:02:04 +02:00 committed by GitHub
parent ff366098e5
commit 482d38ade1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -649,21 +649,22 @@ static uint32_t grab_fields(char *src, uint8_t mult)
} }
if (src[i] == '.') { if (src[i] == '.') {
i++; i++;
if (mult == 0) if (mult == 0) {
break; break;
else }
else {
src[i + mult] = 0; src[i + mult] = 0;
}
} }
tmp *= 10; tmp *= 10;
if (src[i] >= '0' && src[i] <= '9') if (src[i] >= '0' && src[i] <= '9') {
tmp += src[i] - '0'; tmp += src[i] - '0';
if (i >= 15) }
if (i >= 15) {
return 0; // out of bounds return 0; // out of bounds
}
} }
if (isneg) return isneg ? -tmp : tmp; // handle negative altitudes
return -tmp; // handle negative altitudes
else
return tmp;
} }
typedef struct gpsDataNmea_s { typedef struct gpsDataNmea_s {