Compare commits
4 Commits
be2dba8416
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
93f5e93480
|
|||
|
b5435041f2
|
|||
|
235033d633
|
|||
|
7700af06a1
|
@@ -6,13 +6,19 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AKERR_MAX_ERROR_CONTEXT_STRING_LENGTH 1024
|
// FIXME: This is huge now. It used to be 1000 bytes, then I wanted to report errors
|
||||||
|
// related to filesystem paths, which made it grow beyond PATH_MAX, then I started
|
||||||
|
// reporting messages including 2 file paths (PATH_MAX * 2), so now to make the compiler warnings
|
||||||
|
// shut up, it's enormous (PATH_MAX*3).
|
||||||
|
#define AKERR_MAX_ERROR_CONTEXT_STRING_LENGTH 12384
|
||||||
|
|
||||||
#define AKERR_MAX_ERROR_NAME_LENGTH 64
|
#define AKERR_MAX_ERROR_NAME_LENGTH 64
|
||||||
#define AKERR_MAX_ERROR_FNAME_LENGTH 256
|
#define AKERR_MAX_ERROR_FNAME_LENGTH PATH_MAX
|
||||||
#define AKERR_MAX_ERROR_FUNCTION_LENGTH 128
|
#define AKERR_MAX_ERROR_FUNCTION_LENGTH 128
|
||||||
#define AKERR_MAX_ERROR_STACKTRACE_BUF_LENGTH 2048
|
#define AKERR_MAX_ERROR_STACKTRACE_BUF_LENGTH (AKERR_MAX_ERROR_CONTEXT_STRING_LENGTH + AKERR_MAX_ERROR_NAME_LENGTH + AKERR_MAX_ERROR_FNAME_LENGTH + AKERR_MAX_ERROR_FUNCTION_LENGTH + 16)
|
||||||
|
|
||||||
#define AKERR_LAST_ERRNO_VALUE AKERR_LAST_ERRNO_VALUE_SED
|
#define AKERR_LAST_ERRNO_VALUE AKERR_LAST_ERRNO_VALUE_SED
|
||||||
|
|
||||||
@@ -31,6 +37,7 @@
|
|||||||
#define AKERR_BEHAVIOR (AKERR_LAST_ERRNO_VALUE + 13)
|
#define AKERR_BEHAVIOR (AKERR_LAST_ERRNO_VALUE + 13)
|
||||||
#define AKERR_RELATIONSHIP (AKERR_LAST_ERRNO_VALUE + 14)
|
#define AKERR_RELATIONSHIP (AKERR_LAST_ERRNO_VALUE + 14)
|
||||||
#define AKERR_EOF (AKERR_LAST_ERRNO_VALUE + 15)
|
#define AKERR_EOF (AKERR_LAST_ERRNO_VALUE + 15)
|
||||||
|
#define AKERR_CIRCULAR_REFERENCE (AKERR_LAST_ERRNO_VALUE + 16)
|
||||||
|
|
||||||
#ifndef AKERR_MAX_ERR_VALUE
|
#ifndef AKERR_MAX_ERR_VALUE
|
||||||
#define AKERR_MAX_ERR_VALUE (AKERR_LAST_ERRNO_VALUE + 15)
|
#define AKERR_MAX_ERR_VALUE (AKERR_LAST_ERRNO_VALUE + 15)
|
||||||
@@ -179,7 +186,8 @@ void akerr_init_errno(void);
|
|||||||
|
|
||||||
#define VALID(__err_context, __stmt) \
|
#define VALID(__err_context, __stmt) \
|
||||||
__stmt; \
|
__stmt; \
|
||||||
if ( akerr_valid_error_address(__err_context) == 1 ) { \
|
if ( akerr_valid_error_address(__err_context) == 0 ) { \
|
||||||
|
__err_context = NULL; \
|
||||||
FAIL(__err_context, AKERR_BEHAVIOR, "Received (akerr_Error *) from an invalid memory region. (Did the method finish without calling SUCCEED_RETURN?)"); \
|
FAIL(__err_context, AKERR_BEHAVIOR, "Received (akerr_Error *) from an invalid memory region. (Did the method finish without calling SUCCEED_RETURN?)"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ akerr_ErrorContext AKERR_ARRAY_ERROR[AKERR_MAX_ARRAY_ERROR];
|
|||||||
int akerr_valid_error_address(akerr_ErrorContext *ptr)
|
int akerr_valid_error_address(akerr_ErrorContext *ptr)
|
||||||
{
|
{
|
||||||
// Is this within the memory region occupied by AKERR_ARRAY_ERROR?
|
// Is this within the memory region occupied by AKERR_ARRAY_ERROR?
|
||||||
return ((ptr >= &AKERR_ARRAY_ERROR[0]) && (ptr <= &AKERR_ARRAY_ERROR[AKERR_MAX_ARRAY_ERROR-1]));
|
if ( ptr == NULL ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return ((ptr >= &AKERR_ARRAY_ERROR[0]) &&
|
||||||
|
(ptr <= &AKERR_ARRAY_ERROR[AKERR_MAX_ARRAY_ERROR-1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void akerr_default_logger(const char *fmt, ...)
|
void akerr_default_logger(const char *fmt, ...)
|
||||||
@@ -65,6 +69,7 @@ void akerr_init()
|
|||||||
akerr_name_for_status(AKERR_VALUE, "Value Error");
|
akerr_name_for_status(AKERR_VALUE, "Value Error");
|
||||||
akerr_name_for_status(AKERR_BEHAVIOR, "Behavior Error");
|
akerr_name_for_status(AKERR_BEHAVIOR, "Behavior Error");
|
||||||
akerr_name_for_status(AKERR_RELATIONSHIP, "Relationship Error");
|
akerr_name_for_status(AKERR_RELATIONSHIP, "Relationship Error");
|
||||||
|
akerr_name_for_status(AKERR_CIRCULAR_REFERENCE, "Circular Reference Error");
|
||||||
#if (defined(AKERR_USE_STDLIB) && AKERR_USE_STDLIB == 1) || (!defined(AKERR_USE_STDLIB))
|
#if (defined(AKERR_USE_STDLIB) && AKERR_USE_STDLIB == 1) || (!defined(AKERR_USE_STDLIB))
|
||||||
akerr_init_errno();
|
akerr_init_errno();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user