Skip to content
Snippets Groups Projects
Commit b9f0dfe4 authored by Lubos Slovak's avatar Lubos Slovak
Browse files

Renamed common error functions.

refs #705
parent c014e4dc
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,8 @@
* \return Item in the lookup table with the given id or NULL if no such is
* present.
*/
static const _knot_error_table_t *error_lookup_by_id(
const _knot_error_table_t *table, int id)
static const error_table_t *error_lookup_by_id(const error_table_t *table,
int id)
{
while (table->name != 0) {
if (table->id == id) {
......@@ -26,9 +26,9 @@ static const _knot_error_table_t *error_lookup_by_id(
return 0;
}
const char *_knot_strerror(_knot_error_table_t *table, int errno)
const char *error_to_str(error_table_t *table, int errno)
{
const _knot_error_table_t *msg = error_lookup_by_id(table, errno);
const error_table_t *msg = error_lookup_by_id(table, errno);
if (msg != 0) {
return msg->name;
} else {
......@@ -36,7 +36,7 @@ const char *_knot_strerror(_knot_error_table_t *table, int errno)
}
}
int __knot_map_errno(int fallback_value, int arg0, ...)
int _map_errno(int fallback_value, int arg0, ...)
{
/* Iterate all variable-length arguments. */
va_list ap;
......
......@@ -19,7 +19,7 @@
typedef struct error_table_t {
int id;
const char *name;
} _knot_error_table_t;
} error_table_t;
/*!
* \brief Returns error message for the given error code.
......@@ -28,7 +28,7 @@ typedef struct error_table_t {
*
* \return String containing the error message.
*/
const char *_knot_strerror(_knot_error_table_t *table, int errno);
const char *error_to_str(error_table_t *table, int errno);
/*!
* \brief Safe errno mapper that automatically appends sentinel value.
......@@ -42,8 +42,7 @@ const char *_knot_strerror(_knot_error_table_t *table, int errno);
*
* \return Mapped error code.
*/
#define _knot_map_errno(fallback_value, err...) \
__knot_map_errno(fallback_value, err, 0);
#define map_errno(fallback_value, err...) _map_errno(fallback_value, err, 0)
/*!
* \brief Returns a mapped POSIX errcode.
......@@ -58,7 +57,7 @@ const char *_knot_strerror(_knot_error_table_t *table, int errno);
*
* \return Mapped error code.
*/
int __knot_map_errno(int fallback_value, int arg0, ...);
int _map_errno(int fallback_value, int arg0, ...);
#endif /* _KNOT_COMMON_ERROR_H_ */
......
......@@ -6,7 +6,7 @@
#include "common/errors.h"
/*! \brief Table linking error messages to error codes. */
const _knot_error_table_t knot_error_msgs[] = {
const error_table_t knot_error_msgs[] = {
/* Mapped errors. */
{KNOT_EOK, "OK"},
......
......@@ -50,7 +50,7 @@ enum knot_error_t {
KNOT_ERROR_COUNT = 19
};
const _knot_error_table_t knot_error_msgs[KNOT_ERROR_COUNT];
const error_table_t knot_error_msgs[KNOT_ERROR_COUNT];
/*!
* \brief Returns error message for the given error code.
......@@ -59,9 +59,9 @@ const _knot_error_table_t knot_error_msgs[KNOT_ERROR_COUNT];
*
* \return String containing the error message.
*/
inline const char *knot_strerror(int errno)
static inline const char *knot_strerror(int errno)
{
return _knot_strerror(&knot_error_msgs, errno);
return error_to_str(&knot_error_msgs, errno);
}
/*!
......@@ -74,19 +74,7 @@ inline const char *knot_strerror(int errno)
*
* \return Mapped error code.
*/
#define knot_map_errno(err...) _knot_map_errno(KNOT_ERROR, err);
///*!
// * \brief Returns a mapped POSIX errcode.
// *
// * \warning Last error must be KNOT_ERROR, it serves as a fallback and
// * a sentinel value as well. Use knot_map_errno() instead.
// *
// * \param arg0 First mandatory argument.
// * \param ... List of handled codes.
// * \return Mapped error code.
// */
//int _knot_map_errno(int arg0, ...);
#define knot_map_errno(err...) map_errno(KNOT_ERROR, err);
#endif /* _KNOT_ERROR_H_ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment