From 8c8715c4ddb762703b9ef285644693b10e0601a1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 13 Mar 2019 17:14:03 +0300 Subject: [PATCH] fix static analysis issues --- modules/calib3d/src/fisheye.cpp | 5 +++-- modules/core/src/ocl.cpp | 2 ++ modules/imgproc/src/canny.cpp | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index d174c1427b..5fe6b2a08d 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -104,8 +104,9 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints Vec4d k = _D.depth() == CV_32F ? (Vec4d)*_D.getMat().ptr(): *_D.getMat().ptr(); + const bool isJacobianNeeded = jacobian.needed(); JacobianRow *Jn = 0; - if (jacobian.needed()) + if (isJacobianNeeded) { int nvars = 2 + 2 + 1 + 4 + 3 + 3; // f, c, alpha, k, om, T, jacobian.create(2*(int)n, nvars, CV_64F); @@ -153,7 +154,7 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints else xpd[i] = final_point; - if (jacobian.needed()) + if (isJacobianNeeded) { //Vec3d Xi = pdepth == CV_32F ? (Vec3d)Xf[i] : Xd[i]; //Vec3d Y = aff*Xi; diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 3b9e137a1a..745d034373 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -4435,6 +4435,7 @@ public: : size_(size), originPtr_(ptr), alignment_(alignment), ptr_(ptr), allocatedPtr_(NULL) { CV_DbgAssert((alignment & (alignment - 1)) == 0); // check for 2^n + CV_DbgAssert(!readAccess || ptr); if (((size_t)ptr_ & (alignment - 1)) != 0) { allocatedPtr_ = new uchar[size_ + alignment - 1]; @@ -4488,6 +4489,7 @@ public: : size_(rows*step), originPtr_(ptr), alignment_(alignment), ptr_(ptr), allocatedPtr_(NULL), rows_(rows), cols_(cols), step_(step) { CV_DbgAssert((alignment & (alignment - 1)) == 0); // check for 2^n + CV_DbgAssert(!readAccess || ptr != NULL); if (ptr == 0 || ((size_t)ptr_ & (alignment - 1)) != 0) { allocatedPtr_ = new uchar[size_ + extrabytes + alignment - 1]; diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 89eac241c1..355cf37447 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -360,6 +360,8 @@ public: { CV_TRACE_FUNCTION(); + CV_DbgAssert(cn > 0); + Mat dx, dy; AutoBuffer dxMax(0), dyMax(0); std::deque stack, borderPeaksLocal;