diff --git a/include/util/ttrace.h b/include/util/ttrace.h index 579768228a6086fda8656b0dca1430e7da06f9a6..6d40971cc2273ea3d14bfc1a682733cdeb6ecff9 100644 --- a/include/util/ttrace.h +++ b/include/util/ttrace.h @@ -52,6 +52,20 @@ typedef struct STraceId { sprintf(buf, "0x%" PRIx64 ":0x%" PRIx64 "", rootId, msgId); \ } while (0) +#define TRACE_TO_STR_(_traceId, _buf) \ + do { \ + int64_t rootId = (_traceId) != NULL ? (_traceId)->rootId : 0; \ + int64_t msgId = (_traceId) != NULL ? (_traceId)->msgId : 0; \ + char* _t = _buf; \ + _t[0] = '0'; \ + _t[1] = 'x'; \ + _t += titoa(rootId, 16, &_t[2]); \ + _t[0] = ':'; \ + _t[1] = '0'; \ + _t[2] = 'x'; \ + _t += titoa(msgId, 16, &_t[3]); \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/util/tutil.h b/include/util/tutil.h index 513806459df38290fa967644af1a370e931472c5..e0801e529507bd3152037e646895f66c6eefa35c 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -47,7 +47,7 @@ int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]); int32_t taosHexStrToByteArray(char hexstr[], char bytes[]); int32_t tintToHex(uint64_t val, char hex[]); -int32_t tintToStr(uint64_t val, size_t radix, char str[]); +int32_t titoa(uint64_t val, size_t radix, char str[]); char *taosIpStr(uint32_t ipInt); uint32_t ip2uint(const char *const ip_addr); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 53acafeeaacee03e3016a53df7ee4083e29b833c..7ed95a40e20f91ca341d1ef3535e49086d45342c 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1371,7 +1371,7 @@ int32_t doProcessMsgFromServer(void* param) { STraceId* trace = &pMsg->info.traceId; char tbuf[40] = {0}; - TRACE_TO_STR(trace, tbuf); + TRACE_TO_STR_(trace, tbuf); tscDebug("processMsgFromServer handle %p, message: %s, size:%d, code: %s, gtid: %s", pMsg->info.handle, TMSG_INFO(pMsg->msgType), pMsg->contLen, tstrerror(pMsg->code), tbuf); diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 5b274979985bb486895572df8fc3673cfc1e8fec..faf335a62c52011490f64e86cbebf4f63c2122d9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -108,15 +108,15 @@ void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, *(p++) = TD_DIRSEP[0]; *(p++) = 'v'; - p += tintToStr(TD_VID(pTsdb->pVnode), 10, p); + p += titoa(TD_VID(pTsdb->pVnode), 10, p); *(p++) = 'f'; - p += tintToStr(fid, 10, p); + p += titoa(fid, 10, p); memcpy(p, "ver", 3); p += 3; - p += tintToStr(pHeadF->commitID, 10, p); + p += titoa(pHeadF->commitID, 10, p); memcpy(p, ".head", 5); p[5] = 0; } diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index 780dfe910572245b8941592bfd7c91c17c293eed..8beda55c7901791beb5cb4694a43d1e857aa7213 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -336,7 +336,7 @@ int32_t tintToHex(uint64_t val, char hex[]) { return j; } -int32_t tintToStr(uint64_t val, size_t radix, char str[]) { +int32_t titoa(uint64_t val, size_t radix, char str[]) { if (radix < 2 || radix > 16) { return 0; }