diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 0d58dfefaa..1ca419ec4e 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -18,8 +18,6 @@ #include -#include "osDef.h" - #ifdef __cplusplus extern "C" { #endif @@ -48,11 +46,11 @@ const char* terrstr(); char* taosGetErrMsgReturn(); char* taosGetErrMsg(); int32_t* taosGetErrno(); +int32_t* taosGetErrln(); int32_t taosGetErrSize(); - -extern threadlocal int32_t terrno; -extern threadlocal int32_t terrln; -extern threadlocal char terrMsg[ERR_MSG_LEN]; +#define terrno (*taosGetErrno()) +#define terrMsg (taosGetErrMsg()) +#define terrln (*taosGetErrln()) #define SET_ERROR_MSG(MSG, ...) \ snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__) diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 956a2552d4..cf41887142 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -21,14 +21,14 @@ #define TAOS_ERROR_C -threadlocal int32_t terrno; -threadlocal int32_t terrln; -threadlocal char terrMsg[ERR_MSG_LEN]; - +static threadlocal int32_t tsErrno; +static threadlocal int32_t tsErrln; +static threadlocal char tsErrMsgDetail[ERR_MSG_LEN] = {0}; static threadlocal char tsErrMsgReturn[ERR_MSG_LEN] = {0}; -int32_t* taosGetErrno() { return &terrno; } -char* taosGetErrMsg() { return terrMsg; } +int32_t* taosGetErrno() { return &tsErrno; } +int32_t* taosGetErrln() { return &tsErrln; } +char* taosGetErrMsg() { return tsErrMsgDetail; } char* taosGetErrMsgReturn() { return tsErrMsgReturn; } #ifdef TAOS_ERROR_C