* Licensed under the GPL v2. For licencing details see COPYING.
*/
+/** \file error.h \brief Error handling functions and macros. */
+
/**
* This bit indicates whether a number is considered a system error code.
* If yes, the system errno is just the result of clearing this bit from
/** Set the system error bit for the given number. */
#define ERRNO_TO_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT))
+/** The list of all adu error codes with descriptions. */
#define ALL_ERRORS \
_ERROR(SUCCESS, "success") \
_ERROR(SYNTAX, "syntax error") \
*/
#define _ERROR(err, msg) E_ ## err,
+/**
+ * \cond (doxygen can not handle multiple definitions of the same macro).
+ *
+ * This just creates an enum consisting of the first argument of the above
+ * error list.
+ */
enum error_codes {
ALL_ERRORS
};
#undef _ERROR
+
+/*
+ * Here we define the array of error texts used by adu_strerror().
+ */
#define _ERROR(err, msg) msg,
#define DEFINE_ERRLIST char *adu_errlist[] = {ALL_ERRORS}
+/** \endcond */
extern int osl_errno;
+
+/** Contains the description of all adu error codes. */
extern char *adu_errlist[];
*
* \return The error text of \a num.
*/
-static inline const char *adu_strerror(int num)
+_static_inline_ const char *adu_strerror(int num)
{
assert(num > 0);
if (num == E_OSL) {
/**
* Wrapper for osl library calls.
*
+ * \param ret The return value of an osl library function.
+ *
* This should be used for all calls to osl functions that return an osl error
* code. It changes the return value to \p -E_OSL appropriately so that it can
* be used for printing the correct error message.
*
* \return \a ret if \a ret >= 0, \p -E_OSL otherwise.
*/
-static inline int osl(int ret)
+_static_inline_ int osl(int ret)
{
if (ret >= 0)
return ret;