mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
refactor: don't use CV_ErrorNoReturn() internally
This commit is contained in:
@@ -371,7 +371,7 @@ It is possible to alternate error processing by using redirectError().
|
||||
@param _func - function name. Available only when the compiler supports getting it
|
||||
@param _file - source file name where the error has occurred
|
||||
@param _line - line number in the source file where the error has occurred
|
||||
@see CV_Error, CV_Error_, CV_ErrorNoReturn, CV_ErrorNoReturn_, CV_Assert, CV_DbgAssert
|
||||
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
|
||||
*/
|
||||
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
||||
|
||||
@@ -414,8 +414,6 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
|
||||
// We need to use simplified definition for them.
|
||||
#define CV_Error(...) do { abort(); } while (0)
|
||||
#define CV_Error_( code, args ) do { cv::format args; abort(); } while (0)
|
||||
#define CV_ErrorNoReturn(...) do { abort(); } while (0)
|
||||
#define CV_ErrorNoReturn_(...) do { abort(); } while (0)
|
||||
#define CV_Assert_1( expr ) do { if (!(expr)) abort(); } while (0)
|
||||
|
||||
#else // CV_STATIC_ANALYSIS
|
||||
@@ -446,22 +444,22 @@ for example:
|
||||
*/
|
||||
#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
/** same as CV_Error(code,msg), but does not return */
|
||||
#define CV_ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
/** same as CV_Error_(code,args), but does not return */
|
||||
#define CV_ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
#define CV__ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
#ifdef __OPENCV_BUILD
|
||||
#undef CV_Error
|
||||
#define CV_Error CV_ErrorNoReturn
|
||||
#define CV_Error CV__ErrorNoReturn
|
||||
#undef CV_Error_
|
||||
#define CV_Error_ CV_ErrorNoReturn_
|
||||
#define CV_Error_ CV__ErrorNoReturn_
|
||||
#undef CV_Assert_1
|
||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||
#else
|
||||
// backward compatibility
|
||||
#define CV_ErrorNoReturn CV__ErrorNoReturn
|
||||
#define CV_ErrorNoReturn_ CV__ErrorNoReturn_
|
||||
#endif
|
||||
//! @endcond
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ static void dumpOpenCLInformation()
|
||||
|
||||
const Device& device = Device::getDefault();
|
||||
if (!device.available())
|
||||
CV_ErrorNoReturn(Error::OpenCLInitError, "OpenCL device is not available");
|
||||
CV_Error(Error::OpenCLInitError, "OpenCL device is not available");
|
||||
|
||||
DUMP_MESSAGE_STDOUT("Current OpenCL device: ");
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef CL_VERSION_1_2
|
||||
#define CV_REQUIRE_OPENCL_1_2_ERROR CV_ErrorNoReturn(cv::Error::OpenCLApiCallError, "OpenCV compiled without OpenCL v1.2 support, so we can't use functionality from OpenCL v1.2")
|
||||
#define CV_REQUIRE_OPENCL_1_2_ERROR CV_Error(cv::Error::OpenCLApiCallError, "OpenCV compiled without OpenCL v1.2 support, so we can't use functionality from OpenCL v1.2")
|
||||
#endif
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
@@ -50,11 +50,11 @@
|
||||
#include <vector>
|
||||
# include "directx.inc.hpp"
|
||||
#else // HAVE_DIRECTX
|
||||
#define NO_DIRECTX_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without DirectX support")
|
||||
#define NO_DIRECTX_SUPPORT_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without DirectX support")
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_OPENCL
|
||||
# define NO_OPENCL_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenCL support")
|
||||
# define NO_OPENCL_SUPPORT_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without OpenCL support")
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
namespace cv { namespace directx {
|
||||
|
||||
+17
-17
@@ -133,7 +133,7 @@ namespace cv { namespace ocl {
|
||||
int refcount
|
||||
|
||||
#ifndef HAVE_OPENCL
|
||||
#define CV_OPENCL_NO_SUPPORT() CV_ErrorNoReturn(cv::Error::OpenCLApiCallError, "OpenCV build without OpenCL support")
|
||||
#define CV_OPENCL_NO_SUPPORT() CV_Error(cv::Error::OpenCLApiCallError, "OpenCV build without OpenCL support")
|
||||
namespace {
|
||||
struct DummyImpl
|
||||
{
|
||||
@@ -2177,7 +2177,7 @@ struct Context::Impl
|
||||
if (!ptr)
|
||||
{
|
||||
CV_OPENCL_SVM_TRACE_ERROR_P("clSVMAlloc returned NULL...\n");
|
||||
CV_ErrorNoReturn(Error::StsBadArg, "clSVMAlloc returned NULL");
|
||||
CV_Error(Error::StsBadArg, "clSVMAlloc returned NULL");
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -2186,7 +2186,7 @@ struct Context::Impl
|
||||
if (CL_SUCCESS != clEnqueueSVMMap(q, CL_TRUE, CL_MAP_WRITE, ptr, 100, 0, NULL, NULL))
|
||||
{
|
||||
CV_OPENCL_SVM_TRACE_ERROR_P("clEnqueueSVMMap failed...\n");
|
||||
CV_ErrorNoReturn(Error::StsBadArg, "clEnqueueSVMMap FAILED");
|
||||
CV_Error(Error::StsBadArg, "clEnqueueSVMMap FAILED");
|
||||
}
|
||||
clFinish(q);
|
||||
try
|
||||
@@ -2201,12 +2201,12 @@ struct Context::Impl
|
||||
if (CL_SUCCESS != clEnqueueSVMUnmap(q, ptr, 0, NULL, NULL))
|
||||
{
|
||||
CV_OPENCL_SVM_TRACE_ERROR_P("clEnqueueSVMUnmap failed...\n");
|
||||
CV_ErrorNoReturn(Error::StsBadArg, "clEnqueueSVMUnmap FAILED");
|
||||
CV_Error(Error::StsBadArg, "clEnqueueSVMUnmap FAILED");
|
||||
}
|
||||
clFinish(q);
|
||||
if (error)
|
||||
{
|
||||
CV_ErrorNoReturn(Error::StsBadArg, "OpenCL SVM buffer access test was FAILED");
|
||||
CV_Error(Error::StsBadArg, "OpenCL SVM buffer access test was FAILED");
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
@@ -2412,7 +2412,7 @@ void Context::setUseSVM(bool enabled)
|
||||
i->svmInit();
|
||||
if (enabled && !i->svmAvailable)
|
||||
{
|
||||
CV_ErrorNoReturn(Error::StsError, "OpenCL Shared Virtual Memory (SVM) is not supported by OpenCL device");
|
||||
CV_Error(Error::StsError, "OpenCL Shared Virtual Memory (SVM) is not supported by OpenCL device");
|
||||
}
|
||||
i->svmEnabled = enabled;
|
||||
}
|
||||
@@ -2483,7 +2483,7 @@ void attachContext(const String& platformName, void* platformID, void* context,
|
||||
CV_OCL_CHECK(clGetPlatformIDs(0, 0, &cnt));
|
||||
|
||||
if (cnt == 0)
|
||||
CV_ErrorNoReturn(cv::Error::OpenCLApiCallError, "no OpenCL platform available!");
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "no OpenCL platform available!");
|
||||
|
||||
std::vector<cl_platform_id> platforms(cnt);
|
||||
|
||||
@@ -2505,13 +2505,13 @@ void attachContext(const String& platformName, void* platformID, void* context,
|
||||
}
|
||||
|
||||
if (!platformAvailable)
|
||||
CV_ErrorNoReturn(cv::Error::OpenCLApiCallError, "No matched platforms available!");
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "No matched platforms available!");
|
||||
|
||||
// check if platformID corresponds to platformName
|
||||
String actualPlatformName;
|
||||
get_platform_name((cl_platform_id)platformID, actualPlatformName);
|
||||
if (platformName != actualPlatformName)
|
||||
CV_ErrorNoReturn(cv::Error::OpenCLApiCallError, "No matched platforms available!");
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "No matched platforms available!");
|
||||
|
||||
// do not initialize OpenCL context
|
||||
Context ctx = Context::getDefault(false);
|
||||
@@ -3305,7 +3305,7 @@ struct ProgramSource::Impl
|
||||
hash = crc64(sourceAddr_, sourceSize_);
|
||||
break;
|
||||
default:
|
||||
CV_ErrorNoReturn(Error::StsInternal, "Internal error");
|
||||
CV_Error(Error::StsInternal, "Internal error");
|
||||
}
|
||||
sourceHash_ = cv::format("%08llx", hash);
|
||||
isHashUpdated = true;
|
||||
@@ -3427,7 +3427,7 @@ const String& ProgramSource::source() const
|
||||
|
||||
ProgramSource::hash_t ProgramSource::hash() const
|
||||
{
|
||||
CV_ErrorNoReturn(Error::StsNotImplemented, "Removed method: ProgramSource::hash()");
|
||||
CV_Error(Error::StsNotImplemented, "Removed method: ProgramSource::hash()");
|
||||
}
|
||||
|
||||
ProgramSource ProgramSource::fromBinary(const String& module, const String& name,
|
||||
@@ -3597,11 +3597,11 @@ struct Program::Impl
|
||||
}
|
||||
else if (src_->kind_ == ProgramSource::Impl::PROGRAM_SPIRV)
|
||||
{
|
||||
CV_ErrorNoReturn(Error::StsNotImplemented, "OpenCL: SPIR-V is not supported");
|
||||
CV_Error(Error::StsNotImplemented, "OpenCL: SPIR-V is not supported");
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_ErrorNoReturn(Error::StsInternal, "Internal error");
|
||||
CV_Error(Error::StsInternal, "Internal error");
|
||||
}
|
||||
CV_Assert(handle != NULL);
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
@@ -3948,19 +3948,19 @@ void* Program::ptr() const
|
||||
#ifndef OPENCV_REMOVE_DEPRECATED_API
|
||||
const ProgramSource& Program::source() const
|
||||
{
|
||||
CV_ErrorNoReturn(Error::StsNotImplemented, "Removed API");
|
||||
CV_Error(Error::StsNotImplemented, "Removed API");
|
||||
}
|
||||
|
||||
bool Program::read(const String& bin, const String& buildflags)
|
||||
{
|
||||
CV_UNUSED(bin); CV_UNUSED(buildflags);
|
||||
CV_ErrorNoReturn(Error::StsNotImplemented, "Removed API");
|
||||
CV_Error(Error::StsNotImplemented, "Removed API");
|
||||
}
|
||||
|
||||
bool Program::write(String& bin) const
|
||||
{
|
||||
CV_UNUSED(bin);
|
||||
CV_ErrorNoReturn(Error::StsNotImplemented, "Removed API");
|
||||
CV_Error(Error::StsNotImplemented, "Removed API");
|
||||
}
|
||||
|
||||
String Program::getPrefix() const
|
||||
@@ -5627,7 +5627,7 @@ public:
|
||||
}
|
||||
if (id != NULL && strcmp(id, "OCL") != 0)
|
||||
{
|
||||
CV_ErrorNoReturn(cv::Error::StsBadArg, "getBufferPoolController(): unknown BufferPool ID\n");
|
||||
CV_Error(cv::Error::StsBadArg, "getBufferPoolController(): unknown BufferPool ID\n");
|
||||
}
|
||||
return &bufferPool;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ static void* opencl_check_fn(int ID)
|
||||
#endif
|
||||
else
|
||||
{
|
||||
CV_ErrorNoReturn(cv::Error::StsBadArg, "Invalid function ID");
|
||||
CV_Error(cv::Error::StsBadArg, "Invalid function ID");
|
||||
}
|
||||
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
|
||||
if (!func)
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
# include <cuda_gl_interop.h>
|
||||
# endif
|
||||
#else // HAVE_OPENGL
|
||||
# define NO_OPENGL_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenGL support")
|
||||
# define NO_OPENGL_SUPPORT_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without OpenGL support")
|
||||
#endif // HAVE_OPENGL
|
||||
|
||||
using namespace cv;
|
||||
@@ -1563,10 +1563,10 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala
|
||||
# ifdef cl_khr_gl_sharing
|
||||
# define HAVE_OPENCL_OPENGL_SHARING
|
||||
# else
|
||||
# define NO_OPENCL_SHARING_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenCL/OpenGL sharing support")
|
||||
# define NO_OPENCL_SHARING_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without OpenCL/OpenGL sharing support")
|
||||
# endif
|
||||
#else // HAVE_OPENCL
|
||||
# define NO_OPENCL_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenCL support")
|
||||
# define NO_OPENCL_SUPPORT_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without OpenCL support")
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
#if defined(HAVE_OPENGL)
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace
|
||||
#if CV__EXCEPTION_PTR
|
||||
std::rethrow_exception(pException);
|
||||
#else
|
||||
CV_ErrorNoReturn(Error::StsError, "Exception in parallel_for() body: " + exception_message);
|
||||
CV_Error(Error::StsError, "Exception in parallel_for() body: " + exception_message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ char* icvGets( CvFileStorage* fs, char* str, int maxCount )
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
CV_ErrorNoReturn(CV_StsError, "The storage is not opened");
|
||||
CV_Error(CV_StsError, "The storage is not opened");
|
||||
}
|
||||
|
||||
int icvEof( CvFileStorage* fs )
|
||||
|
||||
@@ -76,7 +76,7 @@ static bool param_dumpErrors = utils::getConfigurationParameterBool("OPENCV_DUMP
|
||||
# define CV_ERROR_SET_TERMINATE_HANDLER 1
|
||||
# endif
|
||||
#endif
|
||||
#if CV_ERROR_SET_TERMINATE_HANDLER == 0
|
||||
#if defined(CV_ERROR_SET_TERMINATE_HANDLER) && !CV_ERROR_SET_TERMINATE_HANDLER
|
||||
# undef CV_ERROR_SET_TERMINATE_HANDLER
|
||||
#endif
|
||||
|
||||
@@ -532,7 +532,7 @@ struct HWFeatures
|
||||
"******************************************************************\n");
|
||||
fprintf(stderr, "\nRequired baseline features:\n");
|
||||
checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]), true);
|
||||
CV_ErrorNoReturn(cv::Error::StsAssert, "Missing support for required CPU baseline features. Check OpenCV build configuration and required CPU/HW setup.");
|
||||
CV_Error(cv::Error::StsAssert, "Missing support for required CPU baseline features. Check OpenCV build configuration and required CPU/HW setup.");
|
||||
}
|
||||
|
||||
readSettings(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]));
|
||||
@@ -1657,7 +1657,7 @@ bool utils::getConfigurationParameterBool(const char* name, bool defaultValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CV_ErrorNoReturn(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
|
||||
CV_Error(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1688,7 +1688,7 @@ size_t utils::getConfigurationParameterSizeT(const char* name, size_t defaultVal
|
||||
return v * 1024 * 1024;
|
||||
else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb")
|
||||
return v * 1024;
|
||||
CV_ErrorNoReturn(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
|
||||
CV_Error(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
|
||||
}
|
||||
|
||||
cv::String utils::getConfigurationParameterString(const char* name, const char* defaultValue)
|
||||
|
||||
@@ -265,7 +265,7 @@ struct FileLock::Impl
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_ErrorNoReturn_(Error::StsAssert, ("Can't open lock file: %s", fname));
|
||||
CV_Error_(Error::StsAssert, ("Can't open lock file: %s", fname));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -517,7 +517,7 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu
|
||||
}
|
||||
|
||||
#else
|
||||
#define NOT_IMPLEMENTED CV_ErrorNoReturn(Error::StsNotImplemented, "");
|
||||
#define NOT_IMPLEMENTED CV_Error(Error::StsNotImplemented, "");
|
||||
CV_EXPORTS bool exists(const cv::String& /*path*/) { NOT_IMPLEMENTED }
|
||||
CV_EXPORTS void remove_all(const cv::String& /*path*/) { NOT_IMPLEMENTED }
|
||||
CV_EXPORTS bool createDirectory(const cv::String& /*path*/) { NOT_IMPLEMENTED }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifdef HAVE_VA
|
||||
# include <va/va.h>
|
||||
#else // HAVE_VA
|
||||
# define NO_VA_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without VA support (libva)")
|
||||
# define NO_VA_SUPPORT_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without VA support (libva)")
|
||||
#endif // HAVE_VA
|
||||
|
||||
using namespace cv;
|
||||
|
||||
Reference in New Issue
Block a user