Commit c5e9d1ad authored by Alexander Alekhin's avatar Alexander Alekhin Committed by Maksim Shabunin

macro for static analysis tools

parent 0bc30d38
......@@ -381,6 +381,17 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
#define CV_Func ""
#endif
#ifdef CV_STATIC_ANALYSIS
// In practice, some macro are not processed correctly (noreturn is not detected).
// We need to use simplified definition for them.
#define CV_Error(...) do { abort(); } while (0)
#define CV_Error_(...) do { abort(); } while (0)
#define CV_Assert(cond) do { if (!(cond)) abort(); } while (0)
#define CV_ErrorNoReturn(...) do { abort(); } while (0)
#define CV_ErrorNoReturn_(...) do { abort(); } while (0)
#else // CV_STATIC_ANALYSIS
/** @brief Call the error handler.
Currently, the error handler prints the error code and the error message to the standard
......@@ -421,6 +432,8 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
/** 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__ )
#endif // CV_STATIC_ANALYSIS
/** replaced with CV_Assert(expr) in Debug configuration */
#ifdef _DEBUG
# define CV_DbgAssert(expr) CV_Assert(expr)
......
......@@ -302,6 +302,18 @@ Cv64suf;
# define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif
/****************************************************************************************\
* static analysys *
\****************************************************************************************/
// In practice, some macro are not processed correctly (noreturn is not detected).
// We need to use simplified definition for them.
#ifndef CV_STATIC_ANALYSIS
# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
# define CV_STATIC_ANALYSIS
# endif
#endif
/****************************************************************************************\
* exchange-add operation for atomic operations on reference counters *
\****************************************************************************************/
......
......@@ -463,7 +463,7 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type )
}
break;
default:
return CV_Error( CV_StsBadArg, "" );
CV_Error( CV_StsBadArg, "" ); return;
}
}
else
......@@ -517,7 +517,7 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type )
}
break;
default:
return CV_Error( CV_StsBadArg, "" );
CV_Error( CV_StsBadArg, "" ); return;
}
}
}
......@@ -698,7 +698,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
}
break;
default:
return CV_Error( CV_StsBadArg, "" );
CV_Error( CV_StsBadArg, "" ); return;
}
}
else
......@@ -752,7 +752,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
}
break;
default:
return CV_Error( CV_StsBadArg, "" );
CV_Error( CV_StsBadArg, "" ); return;
}
}
}
......@@ -893,7 +893,7 @@ thresh_64f(const Mat& _src, Mat& _dst, double thresh, double maxval, int type)
}
break;
default:
return CV_Error(CV_StsBadArg, "");
CV_Error(CV_StsBadArg, ""); return;
}
}
else
......@@ -952,7 +952,7 @@ thresh_64f(const Mat& _src, Mat& _dst, double thresh, double maxval, int type)
}
break;
default:
return CV_Error(CV_StsBadArg, "");
CV_Error(CV_StsBadArg, ""); return;
}
}
}
......
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