From e1f22e0e729bb56e6b23af4689edb268846356be Mon Sep 17 00:00:00 2001 From: gitlost Date: Wed, 7 Jul 2021 15:46:02 +0100 Subject: [PATCH] CODE128: make cppcheck out-of-bounds suppression clearer (#233), props Andre Maute --- backend/code128.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/code128.c b/backend/code128.c index 11fc06a8..97eb8901 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -237,10 +237,12 @@ static void c128_set_a(const unsigned char source, char dest[], int values[], in * control characters. */ 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]); 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]); values[(*bar_chars)] = source - 32; } else { /* Should never happen */