$darkmode
netatalk  4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
errchk.h File Reference

Error checking macros. More...

Go to the source code of this file.

Macros

#define EC_INIT   int ret = 0
 
#define EC_STATUS(a)   ret = (a)
 
#define EC_EXIT_STATUS(a)   do { ret = (a); goto cleanup; } while (0)
 
#define EC_FAIL   do { ret = -1; goto cleanup; } while (0)
 
#define EC_FAIL_LOG(...)
 
#define EC_CLEANUP   cleanup
 
#define EC_EXIT   return ret
 
#define EC_ZERO_LOG(a)
 
#define EC_ZERO_LOGSTR(a, b, ...)
 
#define EC_ZERO_LOG_ERR(a, b)
 
#define EC_ZERO(a)
 
#define EC_ZERO_ERR(a, b)
 
#define EC_NEG1_LOG(a)
 
#define EC_NEG1_LOGSTR(a, b, ...)
 
#define EC_NEG1_LOG_ERR(a, b)
 
#define EC_NEG1(a)
 
#define EC_NULL_LOG(a)
 
#define EC_NULL_LOGSTR(a, b, ...)
 
#define EC_NULL_LOG_ERR(a, b)
 
#define EC_NULL(a)
 

Detailed Description

Error checking macros.

See also
./doc/developer/developer.md

We have these macros:

#define EC_NEG1_LOG(a)
Definition: errchk.h:105
#define EC_ZERO_LOG_ERR(a, b)
Definition: errchk.h:79
#define EC_NULL_LOG(a)
Definition: errchk.h:141
#define EC_NEG1_LOG_ERR(a, b)
Definition: errchk.h:123
#define EC_ZERO(a)
Definition: errchk.h:88
#define EC_NULL_LOGSTR(a, b,...)
Definition: errchk.h:150
#define EC_NEG1_LOGSTR(a, b,...)
Definition: errchk.h:114
#define EC_NEG1(a)
Definition: errchk.h:132
#define EC_ZERO_LOGSTR(a, b,...)
Definition: errchk.h:70
#define EC_ZERO_LOG(a)
Definition: errchk.h:61
#define EC_NULL_LOG_ERR(a, b)
Definition: errchk.h:159
#define EC_NULL(a)
Definition: errchk.h:168

A boileplate function template is:

int func(void)
{
...your code here...
}
#define EC_CLEANUP
Definition: errchk.h:28
#define EC_INIT
Definition: errchk.h:18
#define EC_EXIT
Definition: errchk.h:29
#define EC_STATUS(a)
Definition: errchk.h:19

Macro Definition Documentation

◆ EC_CLEANUP

#define EC_CLEANUP   cleanup

◆ EC_EXIT

#define EC_EXIT   return ret

◆ EC_EXIT_STATUS

#define EC_EXIT_STATUS (   a)    do { ret = (a); goto cleanup; } while (0)

◆ EC_FAIL

#define EC_FAIL   do { ret = -1; goto cleanup; } while (0)

◆ EC_FAIL_LOG

#define EC_FAIL_LOG (   ...)
Value:
do { \
LOG(log_error, logtype_default, __VA_ARGS__); \
ret = -1; \
goto cleanup; \
} while (0)
@ logtype_default
Definition: logger.h:34
@ log_error
Definition: logger.h:20

◆ EC_INIT

#define EC_INIT   int ret = 0

◆ EC_NEG1

#define EC_NEG1 (   a)
Value:
do { \
if ((a) == -1) { \
ret = -1; \
goto cleanup; \
} \
} while (0)

◆ EC_NEG1_LOG

#define EC_NEG1_LOG (   a)
Value:
do { \
if ((a) == -1) { \
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \
ret = -1; \
goto cleanup; \
} \
} while (0)

check for return val 0 which is ok, every other is an error, prints errno

◆ EC_NEG1_LOG_ERR

#define EC_NEG1_LOG_ERR (   a,
 
)
Value:
do { \
if ((a) == -1) { \
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \
ret = b; \
goto cleanup; \
} \
} while (0)

◆ EC_NEG1_LOGSTR

#define EC_NEG1_LOGSTR (   a,
  b,
  ... 
)
Value:
do { \
if ((a) == -1) { \
LOG(log_error, logtype_default, b, __VA_ARGS__); \
ret = -1; \
goto cleanup; \
} \
} while (0)

◆ EC_NULL

#define EC_NULL (   a)
Value:
do { \
if ((a) == NULL) { \
ret = -1; \
goto cleanup; \
} \
} while (0)
#define NULL
Definition: utf8util.c:47

◆ EC_NULL_LOG

#define EC_NULL_LOG (   a)
Value:
do { \
if ((a) == NULL) { \
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \
ret = -1; \
goto cleanup; \
} \
} while (0)

check for return val != NULL, prints errno

◆ EC_NULL_LOG_ERR

#define EC_NULL_LOG_ERR (   a,
 
)
Value:
do { \
if ((a) == NULL) { \
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \
ret = b; \
goto cleanup; \
} \
} while (0)

◆ EC_NULL_LOGSTR

#define EC_NULL_LOGSTR (   a,
  b,
  ... 
)
Value:
do { \
if ((a) == NULL) { \
LOG(log_error, logtype_default, b , __VA_ARGS__); \
ret = -1; \
goto cleanup; \
} \
} while (0)

◆ EC_STATUS

#define EC_STATUS (   a)    ret = (a)

◆ EC_ZERO

#define EC_ZERO (   a)
Value:
do { \
if ((a) != 0) { \
ret = -1; \
goto cleanup; \
} \
} while (0)

◆ EC_ZERO_ERR

#define EC_ZERO_ERR (   a,
 
)
Value:
do { \
if ((a) != 0) { \
ret = b; \
goto cleanup; \
} \
} while (0)

◆ EC_ZERO_LOG

#define EC_ZERO_LOG (   a)
Value:
do { \
if ((a) != 0) { \
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \
ret = -1; \
goto cleanup; \
} \
} while (0)

check for return val 0 which is ok, every other is an error, prints errno

◆ EC_ZERO_LOG_ERR

#define EC_ZERO_LOG_ERR (   a,
 
)
Value:
do { \
if ((a) != 0) { \
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \
ret = (b); \
goto cleanup; \
} \
} while (0)

◆ EC_ZERO_LOGSTR

#define EC_ZERO_LOGSTR (   a,
  b,
  ... 
)
Value:
do { \
if ((a) != 0) { \
LOG(log_error, logtype_default, b, __VA_ARGS__); \
ret = -1; \
goto cleanup; \
} \
} while (0)