Project Alice
Loading...
Searching...
No Matches
error_private.h File Reference
#include "../zstd_errors.h"
#include "compiler.h"
#include "debug.h"
#include "zstd_deps.h"
Include dependency graph for error_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ERR_STATIC   static /* this version may generate warnings for unused static functions; disable the relevant warning */
 
#define PREFIX(name)   ZSTD_error_##name
 
#define ERROR(name)   ZSTD_ERROR(name)
 
#define ZSTD_ERROR(name)   ((size_t)-PREFIX(name))
 
#define CHECK_V_F(e, f)
 
#define CHECK_F(f)   do { CHECK_V_F(_var_err__, f); } while (0)
 
#define _FORCE_HAS_FORMAT_STRING(...)
 
#define ERR_QUOTE(str)   #str
 
#define RETURN_ERROR_IF(cond, err, ...)
 
#define RETURN_ERROR(err, ...)
 
#define FORWARD_IF_ERROR(err, ...)
 

Typedefs

typedef ZSTD_ErrorCode ERR_enum
 

Functions

ERR_STATIC unsigned ERR_isError (size_t code)
 
ERR_STATIC ERR_enum ERR_getErrorCode (size_t code)
 
const char * ERR_getErrorString (ERR_enum code)
 
ERR_STATIC const char * ERR_getErrorName (size_t code)
 

Macro Definition Documentation

◆ _FORCE_HAS_FORMAT_STRING

#define _FORCE_HAS_FORMAT_STRING (   ...)
Value:
do { \
if (0) { \
_force_has_format_string(__VA_ARGS__); \
} \
} while (0)

Ignore: this is an internal helper.

We want to force this function invocation to be syntactically correct, but we don't want to force runtime evaluation of its arguments.

Definition at line 103 of file error_private.h.

◆ CHECK_F

#define CHECK_F (   f)    do { CHECK_V_F(_var_err__, f); } while (0)

Definition at line 69 of file error_private.h.

◆ CHECK_V_F

#define CHECK_V_F (   e,
 
)
Value:
size_t const e = f; \
do { \
if (ERR_isError(e)) \
return e; \
} while (0)
ERR_STATIC unsigned ERR_isError(size_t code)
Definition: error_private.h:58

Definition at line 63 of file error_private.h.

◆ ERR_QUOTE

#define ERR_QUOTE (   str)    #str

Definition at line 110 of file error_private.h.

◆ ERR_STATIC

#define ERR_STATIC   static /* this version may generate warnings for unused static functions; disable the relevant warning */

Definition at line 40 of file error_private.h.

◆ ERROR

#define ERROR (   name)    ZSTD_ERROR(name)

Definition at line 55 of file error_private.h.

◆ FORWARD_IF_ERROR

#define FORWARD_IF_ERROR (   err,
  ... 
)
Value:
do { \
size_t const err_code = (err); \
if (ERR_isError(err_code)) { \
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
__FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
RAWLOG(3, ": " __VA_ARGS__); \
RAWLOG(3, "\n"); \
return err_code; \
} \
} while(0)
#define ERR_QUOTE(str)
ERR_STATIC const char * ERR_getErrorName(size_t code)
Definition: error_private.h:78

If the provided expression evaluates to an error code, returns that error code.

In debug modes, prints additional information.

Definition at line 151 of file error_private.h.

◆ PREFIX

#define PREFIX (   name)    ZSTD_error_##name

Definition at line 48 of file error_private.h.

◆ RETURN_ERROR

#define RETURN_ERROR (   err,
  ... 
)
Value:
do { \
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
__FILE__, __LINE__, ERR_QUOTE(ERROR(err))); \
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
RAWLOG(3, ": " __VA_ARGS__); \
RAWLOG(3, "\n"); \
return ERROR(err); \
} while(0)
#define ERROR(name)
Definition: error_private.h:55

Unconditionally return the specified error.

In debug modes, prints additional information.

Definition at line 136 of file error_private.h.

◆ RETURN_ERROR_IF

#define RETURN_ERROR_IF (   cond,
  err,
  ... 
)
Value:
do { \
if (cond) { \
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
__FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
RAWLOG(3, ": " __VA_ARGS__); \
RAWLOG(3, "\n"); \
return ERROR(err); \
} \
} while (0)

Return the specified error if the condition evaluates to true.

In debug modes, prints additional information. In order to do that (particularly, printing the conditional that failed), this can't just wrap RETURN_ERROR().

Definition at line 119 of file error_private.h.

◆ ZSTD_ERROR

#define ZSTD_ERROR (   name)    ((size_t)-PREFIX(name))

Definition at line 56 of file error_private.h.

Typedef Documentation

◆ ERR_enum

Definition at line 47 of file error_private.h.

Function Documentation

◆ ERR_getErrorCode()

ERR_STATIC ERR_enum ERR_getErrorCode ( size_t  code)

Definition at line 60 of file error_private.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ERR_getErrorName()

ERR_STATIC const char * ERR_getErrorName ( size_t  code)

Definition at line 78 of file error_private.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ERR_getErrorString()

const char * ERR_getErrorString ( ERR_enum  code)

Definition at line 15 of file error_private.c.

Here is the caller graph for this function:

◆ ERR_isError()

ERR_STATIC unsigned ERR_isError ( size_t  code)

Definition at line 58 of file error_private.h.

Here is the caller graph for this function: