From bbbbb3ab9dae4df825c094dafbfbdfa5abda9e18 Mon Sep 17 00:00:00 2001 From: W-Mai <1341398182@qq.com> Date: Wed, 11 Jan 2023 04:20:00 +0800 Subject: [PATCH] fix(barcode): type conversion warning (#3913) --- src/libs/barcode/code128.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/libs/barcode/code128.c b/src/libs/barcode/code128.c index 3c019d333..88e329fa8 100644 --- a/src/libs/barcode/code128.c +++ b/src/libs/barcode/code128.c @@ -241,6 +241,8 @@ static signed char code128_switch_code(char from_mode, char to_mode) return 101; } break; + default: + break; } CODE128_ASSERT(0); // Invalid mode switch @@ -250,32 +252,32 @@ static signed char code128_switch_code(char from_mode, char to_mode) static signed char code128a_ascii_to_code(signed char value) { if(value >= ' ' && value <= '_') - return value - ' '; + return (signed char)(value - ' '); else if(value >= 0 && value < ' ') - return value + 64; - else if(value == CODE128_FNC1) + return (signed char)(value + 64); + else if(value == (signed char)CODE128_FNC1) return 102; - else if(value == CODE128_FNC2) + else if(value == (signed char)CODE128_FNC2) return 97; - else if(value == CODE128_FNC3) + else if(value == (signed char)CODE128_FNC3) return 96; - else if(value == CODE128_FNC4) + else if(value == (signed char)CODE128_FNC4) return 101; else return -1; } -static signed char code128b_ascii_to_code(char value) +static signed char code128b_ascii_to_code(signed char value) { - if(value >= 32) // value <= 127 is implied - return value - 32; - else if(value == CODE128_FNC1) + if(value >= ' ') // value <= 127 is implied + return (signed char)(value - ' '); + else if(value == (signed char)CODE128_FNC1) return 102; - else if(value == CODE128_FNC2) + else if(value == (signed char)CODE128_FNC2) return 97; - else if(value == CODE128_FNC3) + else if(value == (signed char)CODE128_FNC3) return 96; - else if(value == CODE128_FNC4) + else if(value == (signed char)CODE128_FNC4) return 100; else return -1;