From 8907acec366da77248a5e33dd2a3c1e9fb62476e Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 15 Jul 2024 16:06:47 +0800 Subject: [PATCH 1/3] define some macro --- include/util/tutil.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/include/util/tutil.h b/include/util/tutil.h index d1a18dc3e8..5360454501 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -56,7 +56,7 @@ void taosIpPort2String(uint32_t ip, uint16_t port, char *str); void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen); -int32_t parseCfgReal(const char* str, double* out); +int32_t parseCfgReal(const char *str, double *out); static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { T_MD5_CTX context; @@ -84,9 +84,9 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar static FORCE_INLINE int32_t taosCreateMD5Hash(char *pBuf, int32_t len) { T_MD5_CTX ctx; tMD5Init(&ctx); - tMD5Update(&ctx, (uint8_t*)pBuf, len); + tMD5Update(&ctx, (uint8_t *)pBuf, len); tMD5Final(&ctx); - char* p = pBuf; + char *p = pBuf; int32_t resLen = 0; for (uint8_t i = 0; i < tListLen(ctx.digest); ++i) { resLen += snprintf(p, 3, "%02x", ctx.digest[i]); @@ -147,6 +147,29 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, #define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member))) +#define TAOS_CHECK_RETURN(CMD) \ + do { \ + int32_t code = (CMD); \ + if (code != TSDB_CODE_SUCCESS) { \ + return (terrno = code); \ + } \ + } while (0) + +#define TAOS_CHECK_GOTO(CODE, LINO, LABEL) \ + do { \ + if ((CODE) != TSDB_CODE_SUCCESS) { \ + if ((LINO) != NULL) { \ + *(LINO) = __LINE__; \ + } \ + goto LABEL; \ + } \ + } while (0) + +#define TAOS_RETURN(code) \ + do { \ + return (terrno = (code)); \ + } while (0) + #ifdef __cplusplus } #endif From bc70d8e3384b460f00f784996f0640c5abc99bf3 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 15 Jul 2024 16:08:20 +0800 Subject: [PATCH 2/3] more define --- include/util/tutil.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/util/tutil.h b/include/util/tutil.h index 5360454501..e6d9b4fdd9 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -147,11 +147,16 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, #define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member))) +#define TAOS_RETURN(code) \ + do { \ + return (terrno = (code)); \ + } while (0) + #define TAOS_CHECK_RETURN(CMD) \ do { \ int32_t code = (CMD); \ if (code != TSDB_CODE_SUCCESS) { \ - return (terrno = code); \ + TAOS_RETURN(code); \ } \ } while (0) @@ -165,11 +170,6 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, } \ } while (0) -#define TAOS_RETURN(code) \ - do { \ - return (terrno = (code)); \ - } while (0) - #ifdef __cplusplus } #endif From d6ba420eb8e8fa58992147ec1d5a7332591ad953 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 15 Jul 2024 16:29:08 +0800 Subject: [PATCH 3/3] more fix --- include/util/tutil.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/util/tutil.h b/include/util/tutil.h index e6d9b4fdd9..d3003c27ba 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -163,8 +163,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, #define TAOS_CHECK_GOTO(CODE, LINO, LABEL) \ do { \ if ((CODE) != TSDB_CODE_SUCCESS) { \ - if ((LINO) != NULL) { \ - *(LINO) = __LINE__; \ + if (LINO) { \ + *((int32_t *)(LINO)) = __LINE__; \ } \ goto LABEL; \ } \