From b93d5556b2fb509c83acb018b151b256bbdfef4a Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sun, 11 Apr 2021 23:16:10 +0200 Subject: [PATCH 1/4] Build: Re-enable Wtype-limits on GCC --- cmake/compiler/gcc/settings.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index af7c3912a..369d052fc 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -5,7 +5,6 @@ target_compile_options(zm-warning-interface -Wextra -Wformat-security -Wno-cast-function-type - -Wno-type-limits -Wno-unused-parameter -Woverloaded-virtual) From 11cfa86de33a39ff357e64677df0f24879d45d46 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sun, 11 Apr 2021 23:34:10 +0200 Subject: [PATCH 2/4] Image: Fix Wtype-limits warnings in Annotate line[c] is a char. There is no possibility for it to be larger than 0xff. Remove these checks. --- src/zm_image.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 753953ccf..cd1b66c0e 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2051,10 +2051,6 @@ void Image::Annotate( for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < char_height; y++, r++, ptr += width ) { unsigned char *temp_ptr = ptr; for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { - if ( line[c] > 0xFF ) { - Warning("Unsupported character %c in %s", line[c], line); - continue; - } uint64_t f = font_bitmap[(line[c] * char_height) + r]; if ( !bg_trans ) memset(temp_ptr, bg_bw_col, char_width); while ( f != 0 ) { @@ -2072,10 +2068,6 @@ void Image::Annotate( for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < char_height; y++, r++, ptr += wc ) { unsigned char *temp_ptr = ptr; for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { - if ( line[c] > 0xFF ) { - Warning("Unsupported character %c in %s", line[c], line); - continue; - } uint64_t f = font_bitmap[(line[c] * char_height) + r]; if ( !bg_trans ) { for ( int i = 0; i < char_width; i++ ) { // We need to set individual r,g,b components @@ -2104,10 +2096,6 @@ void Image::Annotate( for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < char_height; y++, r++, ptr += wc ) { Rgb* temp_ptr = (Rgb*)ptr; for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { - if ( line[c] > 0xFF ) { - Warning("Unsupported character %c in %s", line[c], line); - continue; - } uint64_t f = font_bitmap[(line[c] * char_height) + r]; if ( !bg_trans ) { for ( int i = 0; i < char_width; i++ ) From 4894c319cc0f4220919ff861fdb889d7ff4a8edc Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Mon, 12 Apr 2021 00:20:28 +0200 Subject: [PATCH 3/4] Image: Fix Wtype-limits warnings in zm_convert_yuyv_rgb The intermediate values can be negative. Change the variables to be signed so the clamping later on works correctly. --- src/zm_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index cd1b66c0e..291974267 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -4720,8 +4720,8 @@ void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned lon /* YUYV to RGB24 - relocated from zm_local_camera.cpp */ __attribute__((noinline)) void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { - unsigned int r,g,b; - unsigned int y1,y2,u,v; + int32 r,g,b; + int32 y1,y2,u,v; for(unsigned int i=0; i < count; i += 2, col1 += 4, result += 6) { y1 = col1[0]; u = col1[1]; From 0676f71cd6f0c983996eccc81d4dd3d22f61bbd9 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Mon, 12 Apr 2021 00:44:07 +0200 Subject: [PATCH 4/4] Build/GCC: Suppress -Wclobbered warnings on older compilers There were a high number of false positives with old compilers. Suppress these warnings on them. --- cmake/compiler/gcc/settings.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index 369d052fc..44ca87a1c 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -5,6 +5,7 @@ target_compile_options(zm-warning-interface -Wextra -Wformat-security -Wno-cast-function-type + $<$,10>:-Wno-clobbered> -Wno-unused-parameter -Woverloaded-virtual)