mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Common: char_to_hex returns 0 on invalid char
This commit is contained in:
parent
dd927e1542
commit
b6c5ad450d
@ -97,10 +97,12 @@ size_t strncpy_noterm(char *dest, const char *src, size_t n)
|
||||
*/
|
||||
int16_t char_to_hex(char a)
|
||||
{
|
||||
if (a >= 'A' && a <= 'F')
|
||||
if (a >= 'A' && a <= 'F') {
|
||||
return a - 'A' + 10;
|
||||
else if (a >= 'a' && a <= 'f')
|
||||
} else if (a >= 'a' && a <= 'f') {
|
||||
return a - 'a' + 10;
|
||||
else
|
||||
} else if (a >= '0' && a <= '9') {
|
||||
return a - '0';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user