Commit 643e4f37 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #11375 from alalek:warnings_unreachable_code

parents 9615f8c9 4cbec82a
...@@ -104,13 +104,13 @@ namespace cv { namespace cuda { ...@@ -104,13 +104,13 @@ namespace cv { namespace cuda {
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
static inline void throw_no_cuda() { CV_Error(cv::Error::GpuNotSupported, "The library is compiled without CUDA support"); } static inline CV_NORETURN void throw_no_cuda() { CV_Error(cv::Error::GpuNotSupported, "The library is compiled without CUDA support"); }
#else // HAVE_CUDA #else // HAVE_CUDA
#define nppSafeSetStream(oldStream, newStream) { if(oldStream != newStream) { cudaStreamSynchronize(oldStream); nppSetStream(newStream); } } #define nppSafeSetStream(oldStream, newStream) { if(oldStream != newStream) { cudaStreamSynchronize(oldStream); nppSetStream(newStream); } }
static inline void throw_no_cuda() { CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); } static inline CV_NORETURN void throw_no_cuda() { CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); }
namespace cv { namespace cuda namespace cv { namespace cuda
{ {
......
...@@ -488,7 +488,6 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, Stream& _stream) ...@@ -488,7 +488,6 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, Stream& _stream)
(void) s; (void) s;
(void) _stream; (void) _stream;
throw_no_cuda(); throw_no_cuda();
return *this;
} }
GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream) GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream)
...@@ -497,7 +496,6 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream) ...@@ -497,7 +496,6 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream)
(void) _mask; (void) _mask;
(void) _stream; (void) _stream;
throw_no_cuda(); throw_no_cuda();
return *this;
} }
void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& _stream) const void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& _stream) const
......
...@@ -138,7 +138,6 @@ MatAllocator* cv::cuda::HostMem::getAllocator(AllocType alloc_type) ...@@ -138,7 +138,6 @@ MatAllocator* cv::cuda::HostMem::getAllocator(AllocType alloc_type)
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
(void) alloc_type; (void) alloc_type;
throw_no_cuda(); throw_no_cuda();
return NULL;
#else #else
static std::map<unsigned int, Ptr<MatAllocator> > allocators; static std::map<unsigned int, Ptr<MatAllocator> > allocators;
...@@ -302,7 +301,6 @@ GpuMat cv::cuda::HostMem::createGpuMatHeader() const ...@@ -302,7 +301,6 @@ GpuMat cv::cuda::HostMem::createGpuMatHeader() const
{ {
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
throw_no_cuda(); throw_no_cuda();
return GpuMat();
#else #else
CV_Assert( alloc_type == SHARED ); CV_Assert( alloc_type == SHARED );
......
This diff is collapsed.
...@@ -450,7 +450,6 @@ bool cv::cuda::Stream::queryIfComplete() const ...@@ -450,7 +450,6 @@ bool cv::cuda::Stream::queryIfComplete() const
{ {
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
throw_no_cuda(); throw_no_cuda();
return false;
#else #else
cudaError_t err = cudaStreamQuery(impl_->stream); cudaError_t err = cudaStreamQuery(impl_->stream);
...@@ -526,8 +525,6 @@ Stream& cv::cuda::Stream::Null() ...@@ -526,8 +525,6 @@ Stream& cv::cuda::Stream::Null()
{ {
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
throw_no_cuda(); throw_no_cuda();
static Stream stream;
return stream;
#else #else
const int deviceId = getDevice(); const int deviceId = getDevice();
return initializer.getNullStream(deviceId); return initializer.getNullStream(deviceId);
...@@ -716,7 +713,6 @@ GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, int type) ...@@ -716,7 +713,6 @@ GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, int type)
(void) cols; (void) cols;
(void) type; (void) type;
throw_no_cuda(); throw_no_cuda();
return GpuMat();
#else #else
GpuMat buf(allocator_); GpuMat buf(allocator_);
buf.create(rows, cols, type); buf.create(rows, cols, type);
...@@ -806,7 +802,6 @@ bool cv::cuda::Event::queryIfComplete() const ...@@ -806,7 +802,6 @@ bool cv::cuda::Event::queryIfComplete() const
{ {
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
throw_no_cuda(); throw_no_cuda();
return false;
#else #else
cudaError_t err = cudaEventQuery(impl_->event); cudaError_t err = cudaEventQuery(impl_->event);
...@@ -833,7 +828,6 @@ float cv::cuda::Event::elapsedTime(const Event& start, const Event& end) ...@@ -833,7 +828,6 @@ float cv::cuda::Event::elapsedTime(const Event& start, const Event& end)
(void) start; (void) start;
(void) end; (void) end;
throw_no_cuda(); throw_no_cuda();
return 0.0f;
#else #else
float ms; float ms;
cudaSafeCall( cudaEventElapsedTime(&ms, start.impl_->event, end.impl_->event) ); cudaSafeCall( cudaEventElapsedTime(&ms, start.impl_->event, end.impl_->event) );
......
...@@ -146,7 +146,6 @@ ...@@ -146,7 +146,6 @@
static void* IntGetProcAddress(const char*) static void* IntGetProcAddress(const char*)
{ {
CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support"); CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support");
return 0;
} }
#endif #endif
......
...@@ -57,7 +57,7 @@ using namespace cv::cuda; ...@@ -57,7 +57,7 @@ using namespace cv::cuda;
namespace namespace
{ {
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
inline static void throw_no_ogl() { CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support"); } inline static CV_NORETURN void throw_no_ogl() { CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support"); }
#elif defined _DEBUG #elif defined _DEBUG
inline static bool checkError(const char* file, const int line, const char* func = 0) inline static bool checkError(const char* file, const int line, const char* func = 0)
{ {
...@@ -82,8 +82,7 @@ inline static bool checkError(const char* file, const int line, const char* func ...@@ -82,8 +82,7 @@ inline static bool checkError(const char* file, const int line, const char* func
default: default:
msg = "Unknown error"; msg = "Unknown error";
}; };
cvError(CV_OpenGlApiCallError, func, msg, file, line); cv::errorNoReturn(Error::OpenGlApiCallError, func, msg, file, line);
return false;
} }
return true; return true;
} }
...@@ -697,7 +696,6 @@ cv::ogl::Buffer cv::ogl::Buffer::clone(Target target, bool autoRelease) const ...@@ -697,7 +696,6 @@ cv::ogl::Buffer cv::ogl::Buffer::clone(Target target, bool autoRelease) const
(void) target; (void) target;
(void) autoRelease; (void) autoRelease;
throw_no_ogl(); throw_no_ogl();
return cv::ogl::Buffer();
#else #else
ogl::Buffer buf; ogl::Buffer buf;
buf.copyFrom(*this, target, autoRelease); buf.copyFrom(*this, target, autoRelease);
...@@ -731,7 +729,6 @@ Mat cv::ogl::Buffer::mapHost(Access access) ...@@ -731,7 +729,6 @@ Mat cv::ogl::Buffer::mapHost(Access access)
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
(void) access; (void) access;
throw_no_ogl(); throw_no_ogl();
return Mat();
#else #else
return Mat(rows_, cols_, type_, impl_->mapHost(access)); return Mat(rows_, cols_, type_, impl_->mapHost(access));
#endif #endif
...@@ -750,11 +747,9 @@ GpuMat cv::ogl::Buffer::mapDevice() ...@@ -750,11 +747,9 @@ GpuMat cv::ogl::Buffer::mapDevice()
{ {
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
throw_no_ogl(); throw_no_ogl();
return GpuMat();
#else #else
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
throw_no_cuda(); throw_no_cuda();
return GpuMat();
#else #else
return GpuMat(rows_, cols_, type_, impl_->mapDevice()); return GpuMat(rows_, cols_, type_, impl_->mapDevice());
#endif #endif
...@@ -779,12 +774,10 @@ cuda::GpuMat cv::ogl::Buffer::mapDevice(cuda::Stream& stream) ...@@ -779,12 +774,10 @@ cuda::GpuMat cv::ogl::Buffer::mapDevice(cuda::Stream& stream)
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
(void) stream; (void) stream;
throw_no_ogl(); throw_no_ogl();
return GpuMat();
#else #else
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
(void) stream; (void) stream;
throw_no_cuda(); throw_no_cuda();
return GpuMat();
#else #else
return GpuMat(rows_, cols_, type_, impl_->mapDevice(cuda::StreamAccessor::getStream(stream))); return GpuMat(rows_, cols_, type_, impl_->mapDevice(cuda::StreamAccessor::getStream(stream)));
#endif #endif
...@@ -810,7 +803,6 @@ unsigned int cv::ogl::Buffer::bufId() const ...@@ -810,7 +803,6 @@ unsigned int cv::ogl::Buffer::bufId() const
{ {
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
throw_no_ogl(); throw_no_ogl();
return 0;
#else #else
return impl_->bufId(); return impl_->bufId();
#endif #endif
...@@ -1216,7 +1208,6 @@ unsigned int cv::ogl::Texture2D::texId() const ...@@ -1216,7 +1208,6 @@ unsigned int cv::ogl::Texture2D::texId() const
{ {
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
throw_no_ogl(); throw_no_ogl();
return 0;
#else #else
return impl_->texId(); return impl_->texId();
#endif #endif
......
...@@ -74,7 +74,6 @@ Ptr<Blender> Blender::createDefault(int type, bool try_gpu) ...@@ -74,7 +74,6 @@ Ptr<Blender> Blender::createDefault(int type, bool try_gpu)
if (type == MULTI_BAND) if (type == MULTI_BAND)
return makePtr<MultiBandBlender>(try_gpu); return makePtr<MultiBandBlender>(try_gpu);
CV_Error(Error::StsBadArg, "unsupported blending method"); CV_Error(Error::StsBadArg, "unsupported blending method");
return Ptr<Blender>();
} }
......
...@@ -53,7 +53,6 @@ Ptr<Timelapser> Timelapser::createDefault(int type) ...@@ -53,7 +53,6 @@ Ptr<Timelapser> Timelapser::createDefault(int type)
if (type == CROP) if (type == CROP)
return makePtr<TimelapserCrop>(); return makePtr<TimelapserCrop>();
CV_Error(Error::StsBadArg, "unsupported timelapsing method"); CV_Error(Error::StsBadArg, "unsupported timelapsing method");
return Ptr<Timelapser>();
} }
......
...@@ -163,7 +163,6 @@ Rect cv::detail::PlaneWarperGpu::buildMaps(Size src_size, InputArray K, InputArr ...@@ -163,7 +163,6 @@ Rect cv::detail::PlaneWarperGpu::buildMaps(Size src_size, InputArray K, InputArr
(void)xmap; (void)xmap;
(void)ymap; (void)ymap;
throw_no_cuda(); throw_no_cuda();
return Rect();
#else #else
projector_.setCameraParams(K, R, T); projector_.setCameraParams(K, R, T);
...@@ -198,7 +197,6 @@ Point cv::detail::PlaneWarperGpu::warp(const cuda::GpuMat & src, InputArray K, I ...@@ -198,7 +197,6 @@ Point cv::detail::PlaneWarperGpu::warp(const cuda::GpuMat & src, InputArray K, I
(void)border_mode; (void)border_mode;
(void)dst; (void)dst;
throw_no_cuda(); throw_no_cuda();
return Point();
#else #else
Rect dst_roi = buildMaps(src.size(), K, R, T, d_xmap_, d_ymap_); Rect dst_roi = buildMaps(src.size(), K, R, T, d_xmap_, d_ymap_);
dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type());
...@@ -216,7 +214,6 @@ Rect cv::detail::SphericalWarperGpu::buildMaps(Size src_size, InputArray K, Inpu ...@@ -216,7 +214,6 @@ Rect cv::detail::SphericalWarperGpu::buildMaps(Size src_size, InputArray K, Inpu
(void)xmap; (void)xmap;
(void)ymap; (void)ymap;
throw_no_cuda(); throw_no_cuda();
return Rect();
#else #else
projector_.setCameraParams(K, R); projector_.setCameraParams(K, R);
...@@ -242,7 +239,6 @@ Point cv::detail::SphericalWarperGpu::warp(const cuda::GpuMat & src, InputArray ...@@ -242,7 +239,6 @@ Point cv::detail::SphericalWarperGpu::warp(const cuda::GpuMat & src, InputArray
(void)border_mode; (void)border_mode;
(void)dst; (void)dst;
throw_no_cuda(); throw_no_cuda();
return Point();
#else #else
Rect dst_roi = buildMaps(src.size(), K, R, d_xmap_, d_ymap_); Rect dst_roi = buildMaps(src.size(), K, R, d_xmap_, d_ymap_);
dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type());
...@@ -262,7 +258,6 @@ Rect cv::detail::CylindricalWarperGpu::buildMaps(Size src_size, InputArray K, In ...@@ -262,7 +258,6 @@ Rect cv::detail::CylindricalWarperGpu::buildMaps(Size src_size, InputArray K, In
(void)xmap; (void)xmap;
(void)ymap; (void)ymap;
throw_no_cuda(); throw_no_cuda();
return Rect();
#else #else
projector_.setCameraParams(K, R); projector_.setCameraParams(K, R);
...@@ -288,7 +283,6 @@ Point cv::detail::CylindricalWarperGpu::warp(const cuda::GpuMat & src, InputArra ...@@ -288,7 +283,6 @@ Point cv::detail::CylindricalWarperGpu::warp(const cuda::GpuMat & src, InputArra
(void)border_mode; (void)border_mode;
(void)dst; (void)dst;
throw_no_cuda(); throw_no_cuda();
return Point();
#else #else
Rect dst_roi = buildMaps(src.size(), K, R, d_xmap_, d_ymap_); Rect dst_roi = buildMaps(src.size(), K, R, d_xmap_, d_ymap_);
dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type());
......
...@@ -55,7 +55,6 @@ using namespace cv::superres::detail; ...@@ -55,7 +55,6 @@ using namespace cv::superres::detail;
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_CUDA() Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_CUDA()
{ {
CV_Error(Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); CV_Error(Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<SuperResolution>();
} }
#else // HAVE_CUDA #else // HAVE_CUDA
......
...@@ -196,9 +196,8 @@ Ptr<FrameSource> cv::superres::createFrameSource_Camera(int deviceId) ...@@ -196,9 +196,8 @@ Ptr<FrameSource> cv::superres::createFrameSource_Camera(int deviceId)
Ptr<FrameSource> cv::superres::createFrameSource_Video_CUDA(const String& fileName) Ptr<FrameSource> cv::superres::createFrameSource_Video_CUDA(const String& fileName)
{ {
(void) fileName; CV_UNUSED(fileName);
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<FrameSource>();
} }
#else // HAVE_OPENCV_CUDACODEC #else // HAVE_OPENCV_CUDACODEC
......
...@@ -411,25 +411,21 @@ Ptr<cv::superres::DualTVL1OpticalFlow> cv::superres::createOptFlow_DualTVL1() ...@@ -411,25 +411,21 @@ Ptr<cv::superres::DualTVL1OpticalFlow> cv::superres::createOptFlow_DualTVL1()
Ptr<cv::superres::FarnebackOpticalFlow> cv::superres::createOptFlow_Farneback_CUDA() Ptr<cv::superres::FarnebackOpticalFlow> cv::superres::createOptFlow_Farneback_CUDA()
{ {
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<cv::superres::FarnebackOpticalFlow>();
} }
Ptr<cv::superres::DualTVL1OpticalFlow> cv::superres::createOptFlow_DualTVL1_CUDA() Ptr<cv::superres::DualTVL1OpticalFlow> cv::superres::createOptFlow_DualTVL1_CUDA()
{ {
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<cv::superres::DualTVL1OpticalFlow>();
} }
Ptr<cv::superres::BroxOpticalFlow> cv::superres::createOptFlow_Brox_CUDA() Ptr<cv::superres::BroxOpticalFlow> cv::superres::createOptFlow_Brox_CUDA()
{ {
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<cv::superres::BroxOpticalFlow>();
} }
Ptr<cv::superres::PyrLKOpticalFlow> cv::superres::createOptFlow_PyrLK_CUDA() Ptr<cv::superres::PyrLKOpticalFlow> cv::superres::createOptFlow_PyrLK_CUDA()
{ {
CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<cv::superres::PyrLKOpticalFlow>();
} }
#else // HAVE_OPENCV_CUDAOPTFLOW #else // HAVE_OPENCV_CUDAOPTFLOW
......
...@@ -546,9 +546,8 @@ Mat MotionEstimatorL1::estimate(InputArray points0, InputArray points1, bool *ok ...@@ -546,9 +546,8 @@ Mat MotionEstimatorL1::estimate(InputArray points0, InputArray points1, bool *ok
#ifndef HAVE_CLP #ifndef HAVE_CLP
CV_UNUSED(ok);
CV_Error(Error::StsError, "The library is built without Clp support"); CV_Error(Error::StsError, "The library is built without Clp support");
if (ok) *ok = false;
return Mat::eye(3, 3, CV_32F);
#else #else
......
...@@ -329,12 +329,12 @@ MotionInpainter::MotionInpainter() ...@@ -329,12 +329,12 @@ MotionInpainter::MotionInpainter()
{ {
#ifdef HAVE_OPENCV_CUDAOPTFLOW #ifdef HAVE_OPENCV_CUDAOPTFLOW
setOptFlowEstimator(makePtr<DensePyrLkOptFlowEstimatorGpu>()); setOptFlowEstimator(makePtr<DensePyrLkOptFlowEstimatorGpu>());
#else
CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires CUDA");
#endif
setFlowErrorThreshold(1e-4f); setFlowErrorThreshold(1e-4f);
setDistThreshold(5.f); setDistThreshold(5.f);
setBorderMode(BORDER_REPLICATE); setBorderMode(BORDER_REPLICATE);
#else
CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires CUDA");
#endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment