\hypertarget{group__Eina__Safety__Checks__Group}{}\doxysection{Safety Checks}
\label{group__Eina__Safety__Checks__Group}\index{Safety Checks@{Safety Checks}}


Safety checks are a set of macros to check for parameters or values that should never happen, it is similar in concept to assert(), but will log and return instead of abort() your program.  


\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga1ccf8538d0015b3801ff642e6156843a}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN}}(exp)~  do \{ (void)(!(exp)); \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gab2b07061fc6500dedd9cd41c8d16f95d}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL}}(exp,  val)~  do \{ if (0 \&\& !(exp)) \{ (void)val; \} \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga4e028a0c5bd5743068c1c3f2302dc0e8}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+GOTO}}(exp,  label)~  do \{ if (0 \&\& (exp) == NULL) \{ goto label; \} \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga8b89fd35e22beece51443e29fe585935}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+RETURN}}(exp)~  do \{ (void)(exp); \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga1dbe0d7e3c6b10f4bd49a2a132d73269}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+RETURN\+\_\+\+VAL}}(exp,  val)~  do \{ if (0 \&\& (exp)) \{ (void)val; \} \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gaa083dd2da7053e9b7b39cdc72326d56d}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+GOTO}}(exp,  label)~  do \{ if (0 \&\& (exp)) \{ goto label; \} \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga4c65e34fc0099bb68833d44ad02fb724}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+RETURN}}(exp)~  do \{ (void)(!(exp)); \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gae7cf7b1d66fa9022242e09fd53c06bb2}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+RETURN\+\_\+\+VAL}}(exp,  val)~  do \{ if (0 \&\& !(exp)) \{ (void)val; \} \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gafa24bc421bcbbf70e5512619863fb3fc}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+GOTO}}(exp,  label)~  do \{ if (0 \&\& !(exp)) \{ goto label; \} \} while (0)
\begin{DoxyCompactList}\small\item\em The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_gae44a4462c0f51b9c964f97562bc0c809}\label{group__Eina__Safety__Checks__Group_gae44a4462c0f51b9c964f97562bc0c809}} 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\+\_\+\+Error}} {\bfseries EINA\+\_\+\+ERROR\+\_\+\+SAFETY\+\_\+\+FAILED}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Safety checks are a set of macros to check for parameters or values that should never happen, it is similar in concept to assert(), but will log and return instead of abort() your program. 

\begin{DoxyWarning}{Warning}
{\ttfamily eina\+\_\+safety\+\_\+checks.\+h} should only be included by source files after all other includes and before the source file specific includes. By source file specific includes we mean those that define the functions that are being checked. The reason for such complexity is the trick to avoid compiler optimizations. If compilers are told that some given function will never receive {\ttfamily NULL} (\mbox{\hyperlink{group__Eina__Types__Group_ga1a066aa3069f7e43279021cc1e378fac}{EINA\+\_\+\+ARG\+\_\+\+NONNULL()}}), then the compiler will emit a warning if it detects so (good!) and also will remove any checks for that condition as it believes it will never happen, removing all safety checks! By including {\ttfamily eina\+\_\+safety\+\_\+checks.\+h} last it will redefine \mbox{\hyperlink{group__Eina__Types__Group_ga1a066aa3069f7e43279021cc1e378fac}{EINA\+\_\+\+ARG\+\_\+\+NONNULL()}} to void and compiler warning will not be emitted, but checks will be there. The files already processed with the old macro \mbox{\hyperlink{group__Eina__Types__Group_ga1a066aa3069f7e43279021cc1e378fac}{EINA\+\_\+\+ARG\+\_\+\+NONNULL()}} will still work and emit the warnings.
\end{DoxyWarning}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{comment}{//\ all\ these\ files\ will\ emit\ warning\ from\ EINA\_ARG\_NONNULL()}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Evas.h>}\ \ \textcolor{comment}{//\ third\ party\ headers}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <eina\_safety\_checks.h>}}
\DoxyCodeLine{\textcolor{comment}{//\ all\ the\ files\ below\ will\ NOT\ emit\ warning\ from\ EINA\_ARG\_NONNULL(),}}
\DoxyCodeLine{\textcolor{comment}{//\ but\ this\ is\ required\ to\ have\ the\ functions\ defined\ there\ to\ be\ checked}}
\DoxyCodeLine{\textcolor{comment}{//\ for\ NULL\ pointers}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ "{}my\_functions1.h"{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ "{}my\_functions2.h"{}}}

\end{DoxyCode}


Since these cases should never happen, one may want to keep safety checks enabled during tests but disable them during deploy, not doing any checks at all. This is a common requirement for embedded systems. When to check or not should be set during compile time by using {\ttfamily -\/-\/disable-\/safety-\/checks} or {\ttfamily -\/-\/enable-\/safety-\/checks} options to {\ttfamily configure} script.

Whenever these macros capture an error, \mbox{\hyperlink{group__Eina__Log__Group_ga2e33caeeeb6051526c01b7fea4d6c91b}{EINA\+\_\+\+LOG\+\_\+\+ERR()}} will be called.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Safety__Checks__Group_ga1ccf8538d0015b3801ff642e6156843a}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN()}}, \mbox{\hyperlink{group__Eina__Safety__Checks__Group_gab2b07061fc6500dedd9cd41c8d16f95d}{EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL()}} and other macros. 
\end{DoxySeeAlso}


\doxysubsection{Macro Definition Documentation}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_ga1ccf8538d0015b3801ff642e6156843a}\label{group__Eina__Safety__Checks__Group_ga1ccf8538d0015b3801ff642e6156843a}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_NULL\_RETURN@{EINA\_SAFETY\_ON\_NULL\_RETURN}}
\index{EINA\_SAFETY\_ON\_NULL\_RETURN@{EINA\_SAFETY\_ON\_NULL\_RETURN}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_NULL\_RETURN}{EINA\_SAFETY\_ON\_NULL\_RETURN}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN(\begin{DoxyParamCaption}\item[{}]{exp }\end{DoxyParamCaption})~  do \{ (void)(!(exp)); \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_gab2b07061fc6500dedd9cd41c8d16f95d}\label{group__Eina__Safety__Checks__Group_gab2b07061fc6500dedd9cd41c8d16f95d}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_NULL\_RETURN\_VAL@{EINA\_SAFETY\_ON\_NULL\_RETURN\_VAL}}
\index{EINA\_SAFETY\_ON\_NULL\_RETURN\_VAL@{EINA\_SAFETY\_ON\_NULL\_RETURN\_VAL}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_NULL\_RETURN\_VAL}{EINA\_SAFETY\_ON\_NULL\_RETURN\_VAL}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+RETURN\+\_\+\+VAL(\begin{DoxyParamCaption}\item[{}]{exp,  }\item[{}]{val }\end{DoxyParamCaption})~  do \{ if (0 \&\& !(exp)) \{ (void)val; \} \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\mbox{\texttt{ in}}  & {\em val} & The value to be returned. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_ga4e028a0c5bd5743068c1c3f2302dc0e8}\label{group__Eina__Safety__Checks__Group_ga4e028a0c5bd5743068c1c3f2302dc0e8}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_NULL\_GOTO@{EINA\_SAFETY\_ON\_NULL\_GOTO}}
\index{EINA\_SAFETY\_ON\_NULL\_GOTO@{EINA\_SAFETY\_ON\_NULL\_GOTO}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_NULL\_GOTO}{EINA\_SAFETY\_ON\_NULL\_GOTO}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+NULL\+\_\+\+GOTO(\begin{DoxyParamCaption}\item[{}]{exp,  }\item[{}]{label }\end{DoxyParamCaption})~  do \{ if (0 \&\& (exp) == NULL) \{ goto label; \} \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\mbox{\texttt{ in}}  & {\em label} & The label to jump to. \\
\hline
\end{DoxyParams}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{banshee_8c-example}{banshee.\+c}}.\end{Desc}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_ga8b89fd35e22beece51443e29fe585935}\label{group__Eina__Safety__Checks__Group_ga8b89fd35e22beece51443e29fe585935}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_TRUE\_RETURN@{EINA\_SAFETY\_ON\_TRUE\_RETURN}}
\index{EINA\_SAFETY\_ON\_TRUE\_RETURN@{EINA\_SAFETY\_ON\_TRUE\_RETURN}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_TRUE\_RETURN}{EINA\_SAFETY\_ON\_TRUE\_RETURN}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+RETURN(\begin{DoxyParamCaption}\item[{}]{exp }\end{DoxyParamCaption})~  do \{ (void)(exp); \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\end{DoxyParams}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{banshee_8c-example}{banshee.\+c}}.\end{Desc}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_ga1dbe0d7e3c6b10f4bd49a2a132d73269}\label{group__Eina__Safety__Checks__Group_ga1dbe0d7e3c6b10f4bd49a2a132d73269}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_TRUE\_RETURN\_VAL@{EINA\_SAFETY\_ON\_TRUE\_RETURN\_VAL}}
\index{EINA\_SAFETY\_ON\_TRUE\_RETURN\_VAL@{EINA\_SAFETY\_ON\_TRUE\_RETURN\_VAL}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_TRUE\_RETURN\_VAL}{EINA\_SAFETY\_ON\_TRUE\_RETURN\_VAL}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+RETURN\+\_\+\+VAL(\begin{DoxyParamCaption}\item[{}]{exp,  }\item[{}]{val }\end{DoxyParamCaption})~  do \{ if (0 \&\& (exp)) \{ (void)val; \} \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\mbox{\texttt{ in}}  & {\em val} & The value to be returned. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_gaa083dd2da7053e9b7b39cdc72326d56d}\label{group__Eina__Safety__Checks__Group_gaa083dd2da7053e9b7b39cdc72326d56d}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_TRUE\_GOTO@{EINA\_SAFETY\_ON\_TRUE\_GOTO}}
\index{EINA\_SAFETY\_ON\_TRUE\_GOTO@{EINA\_SAFETY\_ON\_TRUE\_GOTO}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_TRUE\_GOTO}{EINA\_SAFETY\_ON\_TRUE\_GOTO}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+TRUE\+\_\+\+GOTO(\begin{DoxyParamCaption}\item[{}]{exp,  }\item[{}]{label }\end{DoxyParamCaption})~  do \{ if (0 \&\& (exp)) \{ goto label; \} \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\mbox{\texttt{ in}}  & {\em label} & The label to jump to. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_ga4c65e34fc0099bb68833d44ad02fb724}\label{group__Eina__Safety__Checks__Group_ga4c65e34fc0099bb68833d44ad02fb724}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_FALSE\_RETURN@{EINA\_SAFETY\_ON\_FALSE\_RETURN}}
\index{EINA\_SAFETY\_ON\_FALSE\_RETURN@{EINA\_SAFETY\_ON\_FALSE\_RETURN}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_FALSE\_RETURN}{EINA\_SAFETY\_ON\_FALSE\_RETURN}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+RETURN(\begin{DoxyParamCaption}\item[{}]{exp }\end{DoxyParamCaption})~  do \{ (void)(!(exp)); \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_gae7cf7b1d66fa9022242e09fd53c06bb2}\label{group__Eina__Safety__Checks__Group_gae7cf7b1d66fa9022242e09fd53c06bb2}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_FALSE\_RETURN\_VAL@{EINA\_SAFETY\_ON\_FALSE\_RETURN\_VAL}}
\index{EINA\_SAFETY\_ON\_FALSE\_RETURN\_VAL@{EINA\_SAFETY\_ON\_FALSE\_RETURN\_VAL}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_FALSE\_RETURN\_VAL}{EINA\_SAFETY\_ON\_FALSE\_RETURN\_VAL}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+RETURN\+\_\+\+VAL(\begin{DoxyParamCaption}\item[{}]{exp,  }\item[{}]{val }\end{DoxyParamCaption})~  do \{ if (0 \&\& !(exp)) \{ (void)val; \} \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\mbox{\texttt{ in}}  & {\em val} & The value to be returned. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{group__Eina__Safety__Checks__Group_gafa24bc421bcbbf70e5512619863fb3fc}\label{group__Eina__Safety__Checks__Group_gafa24bc421bcbbf70e5512619863fb3fc}} 
\index{Safety Checks@{Safety Checks}!EINA\_SAFETY\_ON\_FALSE\_GOTO@{EINA\_SAFETY\_ON\_FALSE\_GOTO}}
\index{EINA\_SAFETY\_ON\_FALSE\_GOTO@{EINA\_SAFETY\_ON\_FALSE\_GOTO}!Safety Checks@{Safety Checks}}
\doxysubsubsection{\texorpdfstring{EINA\_SAFETY\_ON\_FALSE\_GOTO}{EINA\_SAFETY\_ON\_FALSE\_GOTO}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+SAFETY\+\_\+\+ON\+\_\+\+FALSE\+\_\+\+GOTO(\begin{DoxyParamCaption}\item[{}]{exp,  }\item[{}]{label }\end{DoxyParamCaption})~  do \{ if (0 \&\& !(exp)) \{ goto label; \} \} while (0)}



The macro doesn\textquotesingle{}t do anything unless EINA\+\_\+\+SAFETY\+\_\+\+CHECKS is defined. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em exp} & The expression to be evaluated. \\
\hline
\mbox{\texttt{ in}}  & {\em label} & The label to jump to. \\
\hline
\end{DoxyParams}
