From 14d7b38613c2b7068c128b54f85b76066a09a0d4 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 22 Jul 2015 16:12:31 +0300 Subject: [PATCH] Fixing GCC 4.9 warnings --- 3rdparty/libwebp/CMakeLists.txt | 2 +- modules/imgcodecs/src/grfmt_jpeg.cpp | 4 ++-- modules/imgcodecs/src/grfmt_png.cpp | 6 ++--- modules/imgproc/test/test_convhull.cpp | 22 +++---------------- .../imgproc/test/test_distancetransform.cpp | 2 +- modules/videoio/test/test_positioning.cpp | 2 +- 6 files changed, 11 insertions(+), 27 deletions(-) diff --git a/3rdparty/libwebp/CMakeLists.txt b/3rdparty/libwebp/CMakeLists.txt index 74519ec820..12ca16e8ae 100644 --- a/3rdparty/libwebp/CMakeLists.txt +++ b/3rdparty/libwebp/CMakeLists.txt @@ -40,7 +40,7 @@ if(UNIX) endif() endif() -ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-variable -Wshadow -Wmaybe-uninitialized) +ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-variable -Wunused-function -Wshadow -Wmaybe-uninitialized) ocv_warnings_disable(CMAKE_C_FLAGS /wd4244 /wd4267) # vs2005 set_target_properties(${WEBP_LIBRARY} diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp index efe0058fff..14a2b415dc 100644 --- a/modules/imgcodecs/src/grfmt_jpeg.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg.cpp @@ -395,7 +395,7 @@ int my_jpeg_load_dht (struct jpeg_decompress_struct *info, unsigned char *dht, bool JpegDecoder::readData( Mat& img ) { - bool result = false; + volatile bool result = false; int step = (int)img.step; bool color = img.channels() > 1; @@ -557,7 +557,7 @@ bool JpegEncoder::write( const Mat& img, const std::vector& params ) fileWrapper() : f(0) {} ~fileWrapper() { if(f) fclose(f); } }; - bool result = false; + volatile bool result = false; fileWrapper fw; int width = img.cols, height = img.rows; diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp index 19d3f52caf..95a605f63f 100644 --- a/modules/imgcodecs/src/grfmt_png.cpp +++ b/modules/imgcodecs/src/grfmt_png.cpp @@ -224,7 +224,7 @@ bool PngDecoder::readHeader() bool PngDecoder::readData( Mat& img ) { - bool result = false; + volatile bool result = false; AutoBuffer _buffer(m_height); uchar** buffer = _buffer; int color = img.channels() > 1; @@ -342,10 +342,10 @@ bool PngEncoder::write( const Mat& img, const std::vector& params ) { png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 ); png_infop info_ptr = 0; - FILE* f = 0; + FILE * volatile f = 0; int y, width = img.cols, height = img.rows; int depth = img.depth(), channels = img.channels(); - bool result = false; + volatile bool result = false; AutoBuffer buffer; if( depth != CV_8U && depth != CV_16U ) diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index e7b2886d37..116a4ae3e9 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -1426,7 +1426,7 @@ protected: void run_func(void); int validate_test_results( int test_case_idx ); double max_noise; - float line[6], line0[6]; + AutoBuffer line, line0; int dist_type; double reps, aeps; }; @@ -1439,11 +1439,6 @@ CV_FitLineTest::CV_FitLineTest() max_noise = 0.05; } -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Warray-bounds" -#endif - void CV_FitLineTest::generate_point_set( void* pointsSet ) { RNG& rng = ts->get_rng(); @@ -1515,14 +1510,12 @@ void CV_FitLineTest::generate_point_set( void* pointsSet ) } } -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -# pragma GCC diagnostic pop -#endif - int CV_FitLineTest::prepare_test_case( int test_case_idx ) { RNG& rng = ts->get_rng(); dims = cvtest::randInt(rng) % 2 + 2; + line.allocate(dims * 2); + line0.allocate(dims * 2); min_log_size = MAX(min_log_size,5); max_log_size = MAX(min_log_size,max_log_size); int code = CV_BaseShapeDescrTest::prepare_test_case( test_case_idx ); @@ -1543,11 +1536,6 @@ void CV_FitLineTest::run_func() cv::fitLine(cv::cvarrToMat(points), (cv::Vec6f&)line[0], dist_type, 0, reps, aeps); } -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Warray-bounds" -#endif - int CV_FitLineTest::validate_test_results( int test_case_idx ) { int code = CV_BaseShapeDescrTest::validate_test_results( test_case_idx ); @@ -1626,10 +1614,6 @@ _exit_: return code; } -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -# pragma GCC diagnostic pop -#endif - /****************************************************************************************\ * ContourMoments Test * \****************************************************************************************/ diff --git a/modules/imgproc/test/test_distancetransform.cpp b/modules/imgproc/test/test_distancetransform.cpp index dd3c2e8b41..7d28428437 100644 --- a/modules/imgproc/test/test_distancetransform.cpp +++ b/modules/imgproc/test/test_distancetransform.cpp @@ -158,7 +158,7 @@ cvTsDistTransform( const CvMat* _src, CvMat* _dst, int dist_type, const float init_val = 1e6; float mask[3]; CvMat* temp; - int ofs[16]; + int ofs[16] = {0}; float delta[16]; int tstep, count; diff --git a/modules/videoio/test/test_positioning.cpp b/modules/videoio/test/test_positioning.cpp index 398a160a25..97d84a4e3d 100644 --- a/modules/videoio/test/test_positioning.cpp +++ b/modules/videoio/test/test_positioning.cpp @@ -106,7 +106,7 @@ void CV_VideoPositioningTest::generate_idx_seq(CvCapture* cap, int method) { RNG rng(N); idx.clear(); - for( int i = 0; i < N-1; i++ ) + for( int i = 0; i > 0 && i < N-1; i++ ) idx.push_back(rng.uniform(0, N)); idx.push_back(N-1); std::swap(idx.at(rng.uniform(0, N-1)), idx.at(N-1)); -- GitLab