CODE128: make cppcheck out-of-bounds suppression clearer (#233), props Andre Maute

This commit is contained in:
gitlost 2021-07-07 15:46:02 +01:00
parent 4d9aa96453
commit e1f22e0e72

View File

@ -237,10 +237,12 @@ static void c128_set_a(const unsigned char source, char dest[], int values[], in
* control characters. * control characters.
*/ */
static int c128_set_b(const unsigned char source, char dest[], int values[], int *bar_chars) { static int c128_set_b(const unsigned char source, char dest[], int values[], int *bar_chars) {
if (source > 127 + 32) { /* Suppress cppcheck out-of-bounds warning with + 32 check */ if (source >= 128 + 32) {
strcat(dest, C128Table[source - 32 - 128]); strcat(dest, C128Table[source - 32 - 128]);
values[(*bar_chars)] = source - 32 - 128; values[(*bar_chars)] = source - 32 - 128;
} else if (source <= 127) { /* Suppress cppcheck out-of-bounds warning with <= 127 check */ } else if (source >= 128) { /* Should never happen */
return 0; /* Not reached */
} else if (source >= 32) {
strcat(dest, C128Table[source - 32]); strcat(dest, C128Table[source - 32]);
values[(*bar_chars)] = source - 32; values[(*bar_chars)] = source - 32;
} else { /* Should never happen */ } else { /* Should never happen */