From 5444fe6beb99a9c6739bf19fc8f981d77e9b078c Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 24 Dec 2020 10:12:00 +0800 Subject: [PATCH] tsVersion: refactor to correct format --- src/common/inc/tglobal.h | 2 +- src/common/src/tglobal.c | 15 ++++++++++----- src/util/inc/buildInfo.h | 7 ------- 3 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 src/util/inc/buildInfo.h diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index bf1f22a4ee..e971a9c957 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -161,7 +161,7 @@ extern float tsMinimalLogDirGB; extern float tsReservedTmpDirectorySpace; extern float tsMinimalDataDirGB; extern int32_t tsTotalMemoryMB; -extern int32_t tsVersion; +extern uint32_t tsVersion; // build info extern char version[]; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index f007a82f84..cab234c787 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -201,7 +201,7 @@ float tsAvailDataDirGB = 0; float tsReservedTmpDirectorySpace = 0.1f; float tsMinimalDataDirGB = 0.5f; int32_t tsTotalMemoryMB = 0; -int32_t tsVersion = 0; +uint32_t tsVersion = 0; // log int32_t tsNumOfLogLines = 10000000; @@ -1451,15 +1451,20 @@ int32_t taosCheckGlobalCfg() { // todo refactor tsVersion = 0; - for (int i = 0; i < 10; i++) { + for (int ver = 0, i = 0; i < TSDB_VERSION_LEN; ++i) { if (version[i] >= '0' && version[i] <= '9') { - tsVersion = tsVersion * 10 + (version[i] - '0'); + ver = ver * 10 + (version[i] - '0'); + } else if (version[i] == '.') { + tsVersion |= ver & 0xFF; + tsVersion <<= 8; + + ver = 0; } else if (version[i] == 0) { + tsVersion |= ver & 0xFF; + break; } } - - tsVersion = 10 * tsVersion; tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL; // udp[6035-6039] tcp[6035] tsDnodeDnodePort = tsServerPort + TSDB_PORT_DNODEDNODE; // udp/tcp diff --git a/src/util/inc/buildInfo.h b/src/util/inc/buildInfo.h deleted file mode 100644 index 8d169d618d..0000000000 --- a/src/util/inc/buildInfo.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _TS_BUILD_H_ -#define _TS_BUILD_H_ - -extern const char tsVersion[]; -extern const char tsBuildInfo[]; - -#endif -- GitLab