Skip to content

Commit

Permalink
Merge pull request opencv#21937 from Kumataro:4.x-fix-21911
Browse files Browse the repository at this point in the history
* Fix warnings for clang15

* Fix warnings: Remove unnecessary code

* Fix warnings: Remove unnecessary code
  • Loading branch information
Kumataro authored May 13, 2022
1 parent 2b67bc4 commit 602caa9
Show file tree
Hide file tree
Showing 23 changed files with 28 additions and 52 deletions.
1 change: 1 addition & 0 deletions 3rdparty/ittnotify/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ set_target_properties(${ITT_LIBRARY} PROPERTIES
)

ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wsign-compare)
ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes) # clang15

if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${ITT_LIBRARY} PROPERTIES FOLDER "3rdparty")
Expand Down
2 changes: 2 additions & 0 deletions 3rdparty/libpng/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ add_library(${PNG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})

ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wcast-align -Wimplicit-fallthrough -Wunused-parameter -Wsign-compare)
ocv_warnings_disable(CMAKE_C_FLAGS -Wnull-pointer-subtraction) # clang15
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-but-set-variable) # clang15

set_target_properties(${PNG_LIBRARY}
PROPERTIES OUTPUT_NAME ${PNG_LIBRARY}
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/libtiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-protot
-Wimplicit-fallthrough
)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes) # clang15
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter -Wmissing-prototypes
-Wundef # tiffiop.h: #if __clang_major__ >= 4
)
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/libwebp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-variable -Wunused-function -Wshadow
-Wmissing-prototypes # clang
-Wmissing-declarations # gcc
-Wimplicit-fallthrough
-Wunused-but-set-variable # clang15
)
ocv_warnings_disable(CMAKE_C_FLAGS /wd4244 /wd4267) # vs2005

Expand Down
1 change: 1 addition & 0 deletions 3rdparty/openjpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ project(openjpeg C)

ocv_warnings_disable(CMAKE_C_FLAGS
-Wimplicit-const-int-float-conversion # clang
-Wunused-but-set-variable # clang15
)

#-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion modules/calib3d/src/calibinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ int ChessBoardDetector::checkQuadGroup(std::vector<ChessBoardQuad*>& quad_group,
first = below; // remember the first corner in the next row

// find and store the first row (or column)
for (int j = 1; ; ++j)
while( 1 )
{
right->row = 0;
out_corners.push_back(right);
Expand Down
20 changes: 0 additions & 20 deletions modules/calib3d/test/test_cameracalibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,7 @@ void CV_CameraCalibrationTest::run( int start_from )
/* ----- Compute reprojection error ----- */
double dx,dy;
double rx,ry;
double meanDx,meanDy;
double maxDx = 0.0;
double maxDy = 0.0;

meanDx = 0;
meanDy = 0;
for( currImage = 0; currImage < numImages; currImage++ )
{
double imageMeanDx = 0;
Expand All @@ -585,20 +580,8 @@ void CV_CameraCalibrationTest::run( int start_from )
dx = rx - imagePoints[currImage][currPoint].x;
dy = ry - imagePoints[currImage][currPoint].y;

meanDx += dx;
meanDy += dy;

imageMeanDx += dx*dx;
imageMeanDy += dy*dy;

dx = fabs(dx);
dy = fabs(dy);

if( dx > maxDx )
maxDx = dx;

if( dy > maxDy )
maxDy = dy;
}
goodPerViewErrors[currImage] = sqrt( (imageMeanDx + imageMeanDy) /
(etalonSize.width * etalonSize.height));
Expand All @@ -609,9 +592,6 @@ void CV_CameraCalibrationTest::run( int start_from )
perViewErrors[currImage] = goodPerViewErrors[currImage];
}

meanDx /= numImages * etalonSize.width * etalonSize.height;
meanDy /= numImages * etalonSize.width * etalonSize.height;

/* ========= Compare parameters ========= */
CV_Assert(cameraMatrix.type() == CV_64F && cameraMatrix.size() == Size(3, 3));
CV_Assert(distortion.type() == CV_64F);
Expand Down
3 changes: 1 addition & 2 deletions modules/calib3d/test/test_fisheye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ TEST_F(fisheyeTest, undistortAndDistortImage)
cv::Mat undPointsGt(imageHeight, imageWidth, CV_32FC2);
cv::Mat imageGt(imageHeight, imageWidth, CV_8UC3);

for(int y = 0, k = 0; y < imageHeight; ++y)
for(int y = 0; y < imageHeight; ++y)
{
for(int x = 0; x < imageWidth; ++x)
{
Expand Down Expand Up @@ -261,7 +261,6 @@ TEST_F(fisheyeTest, undistortAndDistortImage)
pixel_gt[2] = pixel[2];
}

k++;
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/core/perf/opencl/perf_matop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ PERF_TEST_P_(OpenCLBuffer, cpu_read)
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
counter += (unsigned)(ptr[x_bytes]);
}
(void)counter; // To avoid -Wunused-but-set-variable
}

SANITY_CHECK_NOTHING();
Expand Down
4 changes: 1 addition & 3 deletions modules/core/src/datastructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ cvCreateChildMemStorage( CvMemStorage * parent )
static void
icvDestroyMemStorage( CvMemStorage* storage )
{
int k = 0;

CvMemBlock *block;
CvMemBlock *dst_top = 0;

Expand All @@ -144,7 +142,7 @@ icvDestroyMemStorage( CvMemStorage* storage )
if( storage->parent )
dst_top = storage->parent->top;

for( block = storage->bottom; block != 0; k++ )
for( block = storage->bottom; block != 0; )
{
CvMemBlock *temp = block;

Expand Down
5 changes: 1 addition & 4 deletions modules/core/src/lpsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,8 @@ static int initialize_simplex(Mat_<double>& c, Mat_<double>& b,double& v,vector<
}

static int inner_simplex(Mat_<double>& c, Mat_<double>& b,double& v,vector<int>& N,vector<int>& B,vector<unsigned int>& indexToRow){
int count=0;
for(;;){
dprintf(("iteration #%d\n",count));
count++;

for(;;){
static MatIterator_<double> pos_ptr;
int e=-1,pos_ctr=0,min_var=INT_MAX;
bool all_nonzero=true;
Expand Down
3 changes: 1 addition & 2 deletions modules/core/src/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,15 +988,13 @@ void parallelForFinalize(const Region& rootRegion)
std::vector<TraceManagerThreadLocal*> threads_ctx;
getTraceManager().tls.gather(threads_ctx);
RegionStatistics parallel_for_stat;
int threads = 0;
for (size_t i = 0; i < threads_ctx.size(); i++)
{
TraceManagerThreadLocal* child_ctx = threads_ctx[i];

if (child_ctx && child_ctx->stackTopRegion() == &rootRegion)
{
CV_LOG_PARALLEL(NULL, "Thread=" << child_ctx->threadID << " " << child_ctx->stat);
threads++;
RegionStatistics child_stat;
child_ctx->stat.grab(child_stat);
parallel_for_stat.append(child_stat);
Expand All @@ -1012,6 +1010,7 @@ void parallelForFinalize(const Region& rootRegion)
}
}
}

float parallel_coeff = std::min(1.0f, duration / (float)(parallel_for_stat.duration));
CV_LOG_PARALLEL(NULL, "parallel_coeff=" << 1.0f / parallel_coeff);
CV_LOG_PARALLEL(NULL, parallel_for_stat);
Expand Down
2 changes: 2 additions & 0 deletions modules/features2d/src/evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ struct SIdx
const SIdx& used;
bool operator()(const SIdx& v) const { return (v.i1 == used.i1 || v.i2 == used.i2); }
UsedFinder& operator=(const UsedFinder&) = delete;
// To avoid -Wdeprecated-copy warning, copy constructor is needed.
UsedFinder(const UsedFinder&) = default;
};
};

Expand Down
3 changes: 1 addition & 2 deletions modules/features2d/src/kaze/KAZEFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void KAZEFeatures::Determinant_Hessian(std::vector<KeyPoint>& kpts)
{
int level = 0;
float smax = 3.0;
int npoints = 0, id_repeated = 0;
int id_repeated = 0;
int left_x = 0, right_x = 0, up_y = 0, down_y = 0;
bool is_extremum = false, is_repeated = false, is_out = false;

Expand Down Expand Up @@ -383,7 +383,6 @@ void KAZEFeatures::Determinant_Hessian(std::vector<KeyPoint>& kpts)
if (is_out == false) {
if (is_repeated == false) {
kpts.push_back(kpts_par_ij);
npoints++;
}
else {
kpts[id_repeated] = kpts_par_ij;
Expand Down
4 changes: 3 additions & 1 deletion modules/features2d/src/keypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ class MaskPredicate
{
return mask.at<uchar>( (int)(key_pt.pt.y + 0.5f), (int)(key_pt.pt.x + 0.5f) ) == 0;
}
MaskPredicate& operator=(const MaskPredicate&) = delete;
// To avoid -Wdeprecated-copy warning, copy constructor is needed.
MaskPredicate(const MaskPredicate&) = default;

private:
const Mat mask;
MaskPredicate& operator=(const MaskPredicate&) = delete;
};

void KeyPointsFilter::runByPixelsMask( std::vector<KeyPoint>& keypoints, const Mat& mask )
Expand Down
2 changes: 0 additions & 2 deletions modules/flann/include/opencv2/flann/index_testing.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ void test_index_precisions(NNIndex<Distance>& index, const Matrix<typename Dista
float p2;

int c1 = 1;
float p1;

float time;
DistanceType dist;
Expand All @@ -270,7 +269,6 @@ void test_index_precisions(NNIndex<Distance>& index, const Matrix<typename Dista
precision = precisions[i];
while (p2<precision) {
c1 = c2;
p1 = p2;
c2 *=2;
p2 = search_with_ground_truth(index, inputData, testData, matches, nn, c2, time, dist, distance, skipMatches);
if ((maxTime> 0)&&(time > maxTime)&&(p2<precision)) return;
Expand Down
4 changes: 3 additions & 1 deletion modules/gapi/src/compiler/passes/exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ namespace
MergeContext mc;

bool there_was_a_merge = false;
#ifdef DEBUG_MERGE
std::size_t iteration = 0u;
#endif
do
{
there_was_a_merge = false;
Expand All @@ -615,8 +617,8 @@ namespace
#ifdef DEBUG_MERGE
GAPI_LOG_INFO(NULL, "Before next merge attempt " << iteration << "...");
merge_debug(g, iteration);
#endif
iteration++;
#endif
auto sorted = pass_helpers::topoSort(im);
for (auto nh : sorted)
{
Expand Down
2 changes: 0 additions & 2 deletions modules/gapi/test/s11n/gapi_s11n_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ TEST_F(S11N_Basic, Test_Bind_RunArgs_MatScalar) {
v[0] = cv::GRunArg{ mat };
v[1] = cv::GRunArg{ scalar };
GRunArgsP output = cv::gapi::bind(v);
unsigned int i = 0;
for (auto it : output)
{
using T = cv::GRunArgP;
Expand All @@ -591,7 +590,6 @@ TEST_F(S11N_Basic, Test_Bind_RunArgs_MatScalar) {
GAPI_Assert(false && "This value type is not supported!"); // ...maybe because of STANDALONE mode.
break;
}
i++;
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/imgproc/test/test_approxpoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ int CV_ApproxPolyTest::check_slice( CvPoint StartPt, CvPoint EndPt,

*_j = j;

(void) TotalErrors; // To avoid -Wunused-but-set-variable warning
//return TotalErrors;
return 0;
}
Expand Down
3 changes: 0 additions & 3 deletions modules/ml/src/kdtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,13 @@ medianPartition( size_t* ofs, int a, int b, const float* vals )
}

float pivot = vals[ofs[middle]];
int less = 0, more = 0;
for( k = a0; k < middle; k++ )
{
CV_Assert(vals[ofs[k]] <= pivot);
less += vals[ofs[k]] < pivot;
}
for( k = b0; k > middle; k-- )
{
CV_Assert(vals[ofs[k]] >= pivot);
more += vals[ofs[k]] > pivot;
}

return vals[ofs[middle]];
Expand Down
4 changes: 4 additions & 0 deletions modules/stitching/src/motion_estimators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ bool BundleAdjusterBase::estimate(const std::vector<ImageFeatures> &features,
CvMat matParams = cvMat(cam_params_);
cvCopy(&matParams, solver.param);

#if ENABLE_LOG
int iter = 0;
#endif
for(;;)
{
const CvMat* _param = 0;
Expand All @@ -287,7 +289,9 @@ bool BundleAdjusterBase::estimate(const std::vector<ImageFeatures> &features,
{
calcError(err);
LOG_CHAT(".");
#if ENABLE_LOG
iter++;
#endif
CvMat tmp = cvMat(err);
cvCopy(&tmp, _err);
}
Expand Down
9 changes: 2 additions & 7 deletions modules/video/test/test_optflowpyrlk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ void CV_OptFlowPyrLKTest::run( int )
const int bad_points_max = 8;

/* test parameters */
double max_err = 0., sum_err = 0;
int pt_cmpd = 0;
double max_err = 0.;
int pt_exceed = 0;
int merr_i = 0, merr_j = 0, merr_k = 0, merr_nan = 0;
int merr_i = 0, merr_nan = 0;
char filename[1000];

cv::Point2f *v = 0, *v2 = 0;
Expand Down Expand Up @@ -155,7 +154,6 @@ void CV_OptFlowPyrLKTest::run( int )
double err;
if( cvIsNaN(v[i].x) || cvIsNaN(v[i].y) )
{
merr_j++;
continue;
}

Expand All @@ -173,15 +171,12 @@ void CV_OptFlowPyrLKTest::run( int )
}

pt_exceed += err > success_error_level;
sum_err += err;
pt_cmpd++;
}
else
{
if( !cvIsNaN( v[i].x ))
{
merr_i = i;
merr_k++;
ts->printf( cvtest::TS::LOG, "The algorithm lost the point #%d\n", i );
code = cvtest::TS::FAIL_BAD_ACCURACY;
break;
Expand Down
2 changes: 0 additions & 2 deletions modules/video/test/test_trackers.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,13 @@ void TrackerTest<Tracker, ROI_t>::checkDataTest()
gt2.open(gtFile.c_str());
ASSERT_TRUE(gt2.is_open()) << gtFile;
string line2;
int bbCounter2 = 0;
while (getline(gt2, line2))
{
vector<string> tokens = splitString(line2, ",");
Rect bb(atoi(tokens.at(0).c_str()), atoi(tokens.at(1).c_str()), atoi(tokens.at(2).c_str()), atoi(tokens.at(3).c_str()));
ASSERT_EQ((size_t)4, tokens.size()) << "Incorrect ground truth file " << gtFile;

bbs.push_back(bb);
bbCounter2++;
}
gt2.close();

Expand Down

0 comments on commit 602caa9

Please sign in to comment.