diff --git a/setup.py b/setup.py index 4298d9e307..db561afc3b 100644 --- a/setup.py +++ b/setup.py @@ -68,6 +68,7 @@ ['/usr/local/opt/openssl/include'] + \ ['aerospike-client-c/modules/common/src/include'] extra_compile_args = [ + '-Winline', '-std=gnu99', '-g', '-Wall', '-fPIC', '-DDEBUG', '-O1', '-fno-common', '-fno-strict-aliasing', '-D_FILE_OFFSET_BITS=64', '-D_REENTRANT', diff --git a/src/include/macros.h b/src/include/macros.h index e7be3f0610..b86baf3341 100644 --- a/src/include/macros.h +++ b/src/include/macros.h @@ -23,40 +23,9 @@ #include // Cannot use multi-line macro because it cannot return a value. -static inline as_status -as_error_set_or_prepend_helper(as_error *err, as_status code, const char *fmt, - const char *func, const char *file, - uint32_t line, ...) -{ - if (!fmt) { - err->code = code; - goto RETURN_EARLY; - } - - va_list ap; - va_start(ap, line); - - char err_msg_to_prepend[AS_ERROR_MESSAGE_MAX_SIZE]; - vsnprintf(err_msg_to_prepend, AS_ERROR_MESSAGE_MAX_SIZE, fmt, ap); - - // Prepend our new error message to the existing one. - char orig_err_msg[AS_ERROR_MESSAGE_MAX_SIZE]; - strncpy(orig_err_msg, err->message, AS_ERROR_MESSAGE_MAX_LEN); - // Handles edge case where max number of chars is copied (without null terminator) - orig_err_msg[AS_ERROR_MESSAGE_MAX_LEN] = '\0'; - - as_error_setall(err, code, err_msg_to_prepend, func, file, line); - - if (strlen(orig_err_msg)) { - as_error_append(err, " -> "); - as_error_append(err, orig_err_msg); - } - - va_end(ap); - -RETURN_EARLY: - return code; -} +as_status as_error_set_or_prepend_helper(as_error *err, as_status code, + const char *fmt, const char *func, + const char *file, uint32_t line, ...); #undef as_error_update diff --git a/src/main/exception.c b/src/main/exception.c index 866cc56330..c751e413d2 100644 --- a/src/main/exception.c +++ b/src/main/exception.c @@ -26,6 +26,40 @@ #include "exception_types.h" #include "macros.h" +as_status as_error_set_or_prepend_helper(as_error *err, as_status code, + const char *fmt, const char *func, + const char *file, uint32_t line, ...) +{ + if (!fmt) { + err->code = code; + goto RETURN_EARLY; + } + + va_list ap; + va_start(ap, line); + + char err_msg_to_prepend[AS_ERROR_MESSAGE_MAX_SIZE]; + vsnprintf(err_msg_to_prepend, AS_ERROR_MESSAGE_MAX_SIZE, fmt, ap); + + // Prepend our new error message to the existing one. + char orig_err_msg[AS_ERROR_MESSAGE_MAX_SIZE]; + strncpy(orig_err_msg, err->message, AS_ERROR_MESSAGE_MAX_LEN); + // Handles edge case where max number of chars is copied (without null terminator) + orig_err_msg[AS_ERROR_MESSAGE_MAX_LEN] = '\0'; + + as_error_setall(err, code, err_msg_to_prepend, func, file, line); + + if (strlen(orig_err_msg)) { + as_error_append(err, " -> "); + as_error_append(err, orig_err_msg); + } + + va_end(ap); + +RETURN_EARLY: + return code; +} + static PyObject *py_exc_module; #define SUBMODULE_NAME "exception"