Replace unsafe memory functions with safe versions
This commit is contained in:
parent
0f3d290c27
commit
215208a985
|
@ -62,7 +62,7 @@ typedef enum { M2C = 0, C2M } ConvType;
|
||||||
#define tstrncpy(dst, src, size) \
|
#define tstrncpy(dst, src, size) \
|
||||||
do { \
|
do { \
|
||||||
(void)strncpy((dst), (src), (size)); \
|
(void)strncpy((dst), (src), (size)); \
|
||||||
(dst)[(size) - 1] = 0; \
|
(dst)[(size)-1] = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
||||||
|
@ -74,10 +74,15 @@ int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
||||||
char *tstrdup(const char *src);
|
char *tstrdup(const char *src);
|
||||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||||
int32_t taosStr2int64(const char *str, int64_t *val);
|
int32_t taosStr2int64(const char *str, int64_t *val);
|
||||||
int32_t taosStr2int16(const char *str, int16_t *val);
|
|
||||||
int32_t taosStr2int32(const char *str, int32_t *val);
|
int32_t taosStr2int32(const char *str, int32_t *val);
|
||||||
|
int32_t taosStr2int16(const char *str, int16_t *val);
|
||||||
int32_t taosStr2int8(const char *str, int8_t *val);
|
int32_t taosStr2int8(const char *str, int8_t *val);
|
||||||
|
|
||||||
|
int32_t taosStr2Uint64(const char *str, uint64_t *val);
|
||||||
|
int32_t taosStr2Uint32(const char *str, uint32_t *val);
|
||||||
|
int32_t taosStr2Uint16(const char *str, uint16_t *val);
|
||||||
|
int32_t taosStr2Uint8(const char *str, uint8_t *val);
|
||||||
|
|
||||||
int32_t taosConvInit(void);
|
int32_t taosConvInit(void);
|
||||||
void taosConvDestroy();
|
void taosConvDestroy();
|
||||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type);
|
iconv_t taosAcquireConv(int32_t *idx, ConvType type);
|
||||||
|
@ -112,9 +117,9 @@ float taosStr2Float(const char *str, char **pEnd);
|
||||||
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size);
|
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size);
|
||||||
int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
|
int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
|
||||||
char *taosStrndup(const char *s, int n);
|
char *taosStrndup(const char *s, int n);
|
||||||
//int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
|
// int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
|
||||||
bool isHex(const char* z, uint32_t n);
|
bool isHex(const char *z, uint32_t n);
|
||||||
bool isValidateHex(const char* z, uint32_t n);
|
bool isValidateHex(const char *z, uint32_t n);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,7 +300,13 @@ void* doConsumeData(void* param) {
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
numOfThreads = atoi(argv[1]);
|
//numOfThreads = atoi(argv[1]);
|
||||||
|
int32_t code = taosStr2int32(argv[1], &numOfThreads);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfThreads = TMAX(numOfThreads, 1);
|
numOfThreads = TMAX(numOfThreads, 1);
|
||||||
|
|
|
@ -27,7 +27,10 @@ int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
||||||
char* temp = strchr(pEp->fqdn, ':');
|
char* temp = strchr(pEp->fqdn, ':');
|
||||||
if (temp) {
|
if (temp) {
|
||||||
*temp = 0;
|
*temp = 0;
|
||||||
pEp->port = atoi(temp + 1);
|
pEp->port = taosStr2UInt16(temp + 1, NULL, 10);
|
||||||
|
if (pEp->port < 0) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEp->port == 0) {
|
if (pEp->port == 0) {
|
||||||
|
@ -282,7 +285,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
locked = 1;
|
locked = 1;
|
||||||
|
|
||||||
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
||||||
_start:
|
_start:
|
||||||
col = startCol;
|
col = startCol;
|
||||||
|
|
||||||
// GRANT_CFG_SKIP;
|
// GRANT_CFG_SKIP;
|
||||||
|
@ -351,7 +354,7 @@ _start:
|
||||||
if (index > 0 && index <= exSize) {
|
if (index > 0 && index <= exSize) {
|
||||||
goto _start;
|
goto _start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pBlock->info.rows = numOfRows;
|
pBlock->info.rows = numOfRows;
|
||||||
_exit:
|
_exit:
|
||||||
if (locked) cfgUnLock(pConf);
|
if (locked) cfgUnLock(pConf);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
|
#include "command.h"
|
||||||
#include "mndArbGroup.h"
|
#include "mndArbGroup.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
#include "thttp.h"
|
#include "thttp.h"
|
||||||
#include "tjson.h"
|
#include "tjson.h"
|
||||||
#include "command.h"
|
|
||||||
|
|
||||||
#define DB_VER_NUMBER 1
|
#define DB_VER_NUMBER 1
|
||||||
#define DB_RESERVE_SIZE 27
|
#define DB_RESERVE_SIZE 27
|
||||||
|
@ -416,7 +416,12 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
|
||||||
return TSDB_CODE_MND_INVALID_DB;
|
return TSDB_CODE_MND_INVALID_DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t acctId = atoi(dbName);
|
int32_t acctId;
|
||||||
|
int32_t code = taosStr2int32(dbName, &acctId);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
if (acctId != pUser->acctId) {
|
if (acctId != pUser->acctId) {
|
||||||
return TSDB_CODE_MND_INVALID_DB_ACCT;
|
return TSDB_CODE_MND_INVALID_DB_ACCT;
|
||||||
}
|
}
|
||||||
|
@ -2386,7 +2391,8 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
||||||
|
|
||||||
char durationVstr[128] = {0};
|
char durationVstr[128] = {0};
|
||||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE, pDb->cfg.daysPerFile);
|
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE,
|
||||||
|
pDb->cfg.daysPerFile);
|
||||||
|
|
||||||
varDataSetLen(durationVstr, len);
|
varDataSetLen(durationVstr, len);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
|
@ -462,7 +462,7 @@ int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
||||||
dInfo.isMnode = 0;
|
dInfo.isMnode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(taosArrayPush(pDnodeInfo, &dInfo) == NULL){
|
if (taosArrayPush(pDnodeInfo, &dInfo) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
break;
|
break;
|
||||||
|
@ -471,12 +471,12 @@ int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_MONITOR_PARA(para,err) \
|
#define CHECK_MONITOR_PARA(para, err) \
|
||||||
if (pCfg->monitorParas.para != para) { \
|
if (pCfg->monitorParas.para != para) { \
|
||||||
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
||||||
terrno = err; \
|
terrno = err; \
|
||||||
return err;\
|
return err; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const SClusterCfg *pCfg) {
|
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const SClusterCfg *pCfg) {
|
||||||
CHECK_MONITOR_PARA(tsEnableMonitor, DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH);
|
CHECK_MONITOR_PARA(tsEnableMonitor, DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH);
|
||||||
|
@ -487,7 +487,8 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
||||||
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
||||||
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id, pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
|
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id,
|
||||||
|
pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
|
||||||
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS;
|
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS;
|
||||||
return DND_REASON_STATUS_MONITOR_NOT_MATCH;
|
return DND_REASON_STATUS_MONITOR_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
@ -583,8 +584,8 @@ static bool mndUpdateMnodeState(SMnodeObj *pObj, SMnodeLoad *pMload) {
|
||||||
return stateChanged;
|
return stateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char* tsMonFwUri;
|
extern char *tsMonFwUri;
|
||||||
extern char* tsMonSlowLogUri;
|
extern char *tsMonSlowLogUri;
|
||||||
static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SStatisReq statisReq = {0};
|
SStatisReq statisReq = {0};
|
||||||
|
@ -596,9 +597,9 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
mInfo("process statis req,\n %s", statisReq.pCont);
|
mInfo("process statis req,\n %s", statisReq.pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statisReq.type == MONITOR_TYPE_COUNTER){
|
if (statisReq.type == MONITOR_TYPE_COUNTER) {
|
||||||
monSendContent(statisReq.pCont, tsMonFwUri);
|
monSendContent(statisReq.pCont, tsMonFwUri);
|
||||||
}else if(statisReq.type == MONITOR_TYPE_SLOW_LOG){
|
} else if (statisReq.type == MONITOR_TYPE_SLOW_LOG) {
|
||||||
monSendContent(statisReq.pCont, tsMonSlowLogUri);
|
monSendContent(statisReq.pCont, tsMonSlowLogUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,27 +1059,27 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getSlowLogScopeString(int32_t scope, char* result){
|
static void getSlowLogScopeString(int32_t scope, char *result) {
|
||||||
if(scope == SLOW_LOG_TYPE_NULL) {
|
if (scope == SLOW_LOG_TYPE_NULL) {
|
||||||
(void)strcat(result, "NONE");
|
(void)strcat(result, "NONE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while(scope > 0){
|
while (scope > 0) {
|
||||||
if(scope & SLOW_LOG_TYPE_QUERY) {
|
if (scope & SLOW_LOG_TYPE_QUERY) {
|
||||||
(void)strcat(result, "QUERY");
|
(void)strcat(result, "QUERY");
|
||||||
scope &= ~SLOW_LOG_TYPE_QUERY;
|
scope &= ~SLOW_LOG_TYPE_QUERY;
|
||||||
} else if(scope & SLOW_LOG_TYPE_INSERT) {
|
} else if (scope & SLOW_LOG_TYPE_INSERT) {
|
||||||
(void)strcat(result, "INSERT");
|
(void)strcat(result, "INSERT");
|
||||||
scope &= ~SLOW_LOG_TYPE_INSERT;
|
scope &= ~SLOW_LOG_TYPE_INSERT;
|
||||||
} else if(scope & SLOW_LOG_TYPE_OTHERS) {
|
} else if (scope & SLOW_LOG_TYPE_OTHERS) {
|
||||||
(void)strcat(result, "OTHERS");
|
(void)strcat(result, "OTHERS");
|
||||||
scope &= ~SLOW_LOG_TYPE_OTHERS;
|
scope &= ~SLOW_LOG_TYPE_OTHERS;
|
||||||
} else{
|
} else {
|
||||||
(void)printf("invalid slow log scope:%d", scope);
|
(void)printf("invalid slow log scope:%d", scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scope > 0) {
|
if (scope > 0) {
|
||||||
(void)strcat(result, "|");
|
(void)strcat(result, "|");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1538,7 +1539,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
TAOS_CHECK_GOTO (mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
TAOS_CHECK_GOTO(mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
||||||
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
|
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
|
||||||
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
|
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
|
||||||
code = TSDB_CODE_INVALID_CFG;
|
code = TSDB_CODE_INVALID_CFG;
|
||||||
|
@ -1881,11 +1882,19 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
||||||
if (' ' == pMCfgReq->config[optLen]) {
|
if (' ' == pMCfgReq->config[optLen]) {
|
||||||
// 'key value'
|
// 'key value'
|
||||||
if (strlen(pMCfgReq->value) != 0) goto _err;
|
if (strlen(pMCfgReq->value) != 0) goto _err;
|
||||||
*pOutValue = atoi(pMCfgReq->config + optLen + 1);
|
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("dnode:%d, failed to get cfg since code: %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 'key' 'value'
|
// 'key' 'value'
|
||||||
if (strlen(pMCfgReq->value) == 0) goto _err;
|
if (strlen(pMCfgReq->value) == 0) goto _err;
|
||||||
*pOutValue = atoi(pMCfgReq->value);
|
code = taosStr2int32(pMCfgReq->value, pOutValue);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("dnode:%d, failed to get cfg since code: %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
|
|
@ -190,7 +190,14 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
|
||||||
char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
|
char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
|
||||||
if (tsdbFilePrefixPos == NULL) continue;
|
if (tsdbFilePrefixPos == NULL) continue;
|
||||||
|
|
||||||
int32_t tsdbFileVgId = atoi(tsdbFilePrefixPos + prefixLen);
|
int32_t tsdbFileVgId = 0; // atoi(tsdbFilePrefixPos + prefixLen);
|
||||||
|
ret = taosStr2int32(tsdbFilePrefixPos + prefixLen, &tsdbFileVgId);
|
||||||
|
if (ret != 0) {
|
||||||
|
vError("vgId:%d, failed to get tsdb file vgid since %s", dstVgId, tstrerror(ret));
|
||||||
|
tfsClosedir(tsdbDir);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (tsdbFileVgId == srcVgId) {
|
if (tsdbFileVgId == srcVgId) {
|
||||||
char *tsdbFileSurfixPos = tsdbFilePrefixPos + prefixLen + vnodeVgroupIdLen(srcVgId);
|
char *tsdbFileSurfixPos = tsdbFilePrefixPos + prefixLen + vnodeVgroupIdLen(srcVgId);
|
||||||
|
|
||||||
|
|
|
@ -2872,7 +2872,9 @@ static int32_t getIpV4RangeFromWhitelistItem(char* ipRange, SIpV4Range* pIpRange
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
if (uv_inet_pton(AF_INET, ipCopy, &addr) == 0) {
|
if (uv_inet_pton(AF_INET, ipCopy, &addr) == 0) {
|
||||||
int prefix = atoi(slash + 1);
|
int32_t prefix = 0;
|
||||||
|
code = taosStr2int32(slash + 1, &prefix);
|
||||||
|
if (code == 0) {
|
||||||
if (prefix < 0 || prefix > 32) {
|
if (prefix < 0 || prefix > 32) {
|
||||||
code = TSDB_CODE_PAR_INVALID_IP_RANGE;
|
code = TSDB_CODE_PAR_INVALID_IP_RANGE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2880,6 +2882,7 @@ static int32_t getIpV4RangeFromWhitelistItem(char* ipRange, SIpV4Range* pIpRange
|
||||||
pIpRange->mask = prefix;
|
pIpRange->mask = prefix;
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
code = TSDB_CODE_PAR_INVALID_IP_RANGE;
|
code = TSDB_CODE_PAR_INVALID_IP_RANGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,20 @@ int32_t taosStr2int64(const char *str, int64_t *val) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t taosStr2int32(const char *str, int32_t *val) {
|
||||||
|
OS_PARAM_CHECK(str);
|
||||||
|
OS_PARAM_CHECK(val);
|
||||||
|
int64_t tmp = 0;
|
||||||
|
int32_t code = taosStr2int64(str, &tmp);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
} else if (tmp > INT32_MAX || tmp < INT32_MIN) {
|
||||||
|
return TAOS_SYSTEM_ERROR(ERANGE);
|
||||||
|
} else {
|
||||||
|
*val = (int32_t)tmp;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
int32_t taosStr2int16(const char *str, int16_t *val) {
|
int32_t taosStr2int16(const char *str, int16_t *val) {
|
||||||
OS_PARAM_CHECK(str);
|
OS_PARAM_CHECK(str);
|
||||||
OS_PARAM_CHECK(val);
|
OS_PARAM_CHECK(val);
|
||||||
|
@ -147,21 +161,6 @@ int32_t taosStr2int16(const char *str, int16_t *val) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosStr2int32(const char *str, int32_t *val) {
|
|
||||||
OS_PARAM_CHECK(str);
|
|
||||||
OS_PARAM_CHECK(val);
|
|
||||||
int64_t tmp = 0;
|
|
||||||
int32_t code = taosStr2int64(str, &tmp);
|
|
||||||
if (code) {
|
|
||||||
return code;
|
|
||||||
} else if (tmp > INT32_MAX || tmp < INT32_MIN) {
|
|
||||||
return TAOS_SYSTEM_ERROR(ERANGE);
|
|
||||||
} else {
|
|
||||||
*val = (int32_t)tmp;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t taosStr2int8(const char *str, int8_t *val) {
|
int32_t taosStr2int8(const char *str, int8_t *val) {
|
||||||
OS_PARAM_CHECK(str);
|
OS_PARAM_CHECK(str);
|
||||||
OS_PARAM_CHECK(val);
|
OS_PARAM_CHECK(val);
|
||||||
|
@ -177,6 +176,67 @@ int32_t taosStr2int8(const char *str, int8_t *val) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t taosStr2Uint64(const char *str, uint64_t *val) {
|
||||||
|
if (str == NULL || val == NULL) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
char *endptr = NULL;
|
||||||
|
uint64_t ret = strtoull(str, &endptr, 10);
|
||||||
|
if (errno == ERANGE && (ret == ULLONG_MAX)) {
|
||||||
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
|
} else if (errno == EINVAL && ret == 0) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
} else {
|
||||||
|
*val = ret;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t taosStr2Uint32(const char *str, uint32_t *val) {
|
||||||
|
OS_PARAM_CHECK(str);
|
||||||
|
OS_PARAM_CHECK(val);
|
||||||
|
uint64_t tmp = 0;
|
||||||
|
int32_t code = taosStr2Uint64(str, &tmp);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
} else if (tmp > UINT32_MAX) {
|
||||||
|
return TAOS_SYSTEM_ERROR(ERANGE);
|
||||||
|
} else {
|
||||||
|
*val = (int32_t)tmp;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t taosStr2Uint16(const char *str, uint16_t *val) {
|
||||||
|
OS_PARAM_CHECK(str);
|
||||||
|
OS_PARAM_CHECK(val);
|
||||||
|
uint64_t tmp = 0;
|
||||||
|
int32_t code = taosStr2Uint64(str, &tmp);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
} else if (tmp > UINT16_MAX) {
|
||||||
|
return TAOS_SYSTEM_ERROR(ERANGE);
|
||||||
|
} else {
|
||||||
|
*val = (int16_t)tmp;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t taosStr2Uint8(const char *str, uint8_t *val) {
|
||||||
|
OS_PARAM_CHECK(str);
|
||||||
|
OS_PARAM_CHECK(val);
|
||||||
|
uint64_t tmp = 0;
|
||||||
|
int32_t code = taosStr2Uint64(str, &tmp);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
} else if (tmp > UINT8_MAX) {
|
||||||
|
return TAOS_SYSTEM_ERROR(ERANGE);
|
||||||
|
} else {
|
||||||
|
*val = (int8_t)tmp;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) {
|
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) {
|
||||||
if ((f1_ucs4 == NULL || f2_ucs4 == NULL)) {
|
if ((f1_ucs4 == NULL || f2_ucs4 == NULL)) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -289,7 +349,7 @@ void taosConvDestroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type) {
|
iconv_t taosAcquireConv(int32_t *idx, ConvType type) {
|
||||||
if(idx == NULL) {
|
if (idx == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return (iconv_t)-1;
|
return (iconv_t)-1;
|
||||||
}
|
}
|
||||||
|
@ -356,7 +416,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
|
||||||
if (ucs4_max_len == 0) {
|
if (ucs4_max_len == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(ucs4_max_len < 0 || mbs == NULL || ucs4 == NULL) {
|
if (ucs4_max_len < 0 || mbs == NULL || ucs4 == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -401,7 +461,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
||||||
if (ucs4_max_len == 0) {
|
if (ucs4_max_len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(ucs4_max_len < 0 || ucs4 == NULL || mbs == NULL) {
|
if (ucs4_max_len < 0 || ucs4 == NULL || mbs == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +499,7 @@ int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t c
|
||||||
if (ucs4_max_len == 0) {
|
if (ucs4_max_len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(ucs4_max_len < 0 || ucs4 == NULL || mbs == NULL) {
|
if (ucs4_max_len < 0 || ucs4 == NULL || mbs == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -461,7 +521,7 @@ int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t c
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosValidateEncodec(const char *encodec) {
|
bool taosValidateEncodec(const char *encodec) {
|
||||||
if(encodec == NULL) {
|
if (encodec == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -513,7 +573,7 @@ int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosHexDecode(const char *src, char *dst, int32_t len) {
|
int32_t taosHexDecode(const char *src, char *dst, int32_t len) {
|
||||||
if(!src || !dst || len <= 0) {
|
if (!src || !dst || len <= 0) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -558,7 +618,8 @@ int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size) {
|
||||||
|
|
||||||
int32_t taosWcharToMb(char *pStr, TdWchar wchar) {
|
int32_t taosWcharToMb(char *pStr, TdWchar wchar) {
|
||||||
OS_PARAM_CHECK(pStr);
|
OS_PARAM_CHECK(pStr);
|
||||||
return wctomb(pStr, wchar); }
|
return wctomb(pStr, wchar);
|
||||||
|
}
|
||||||
|
|
||||||
char *taosStrCaseStr(const char *str, const char *pattern) {
|
char *taosStrCaseStr(const char *str, const char *pattern) {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
|
@ -580,7 +641,7 @@ char *taosStrCaseStr(const char *str, const char *pattern) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
|
int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -592,7 +653,7 @@ int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
|
uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +665,7 @@ uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
|
int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +677,7 @@ int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
|
uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -628,7 +689,7 @@ uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
|
int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +701,7 @@ int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
|
uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +713,7 @@ uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) {
|
int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -661,7 +722,7 @@ int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
|
uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -673,7 +734,7 @@ uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double taosStr2Double(const char *str, char **pEnd) {
|
double taosStr2Double(const char *str, char **pEnd) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -682,7 +743,7 @@ double taosStr2Double(const char *str, char **pEnd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float taosStr2Float(const char *str, char **pEnd) {
|
float taosStr2Float(const char *str, char **pEnd) {
|
||||||
if(str == NULL) {
|
if (str == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -698,7 +759,7 @@ bool isHex(const char *z, uint32_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidateHex(const char *z, uint32_t n) {
|
bool isValidateHex(const char *z, uint32_t n) {
|
||||||
if(!z) {
|
if (!z) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,17 +151,19 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetBool(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetBool(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
|
int32_t code = 0;
|
||||||
bool tmp = false;
|
bool tmp = false;
|
||||||
if (strcasecmp(value, "true") == 0) {
|
if (strcasecmp(value, "true") == 0) {
|
||||||
tmp = true;
|
tmp = true;
|
||||||
}
|
}
|
||||||
if (atoi(value) > 0) {
|
int32_t val = 0;
|
||||||
|
if ((code = taosStr2int32(value, &val)) == 0 && val > 0) {
|
||||||
tmp = true;
|
tmp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->bval = tmp;
|
pItem->bval = tmp;
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetInt32(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetInt32(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
|
@ -258,6 +260,7 @@ static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType
|
||||||
|
|
||||||
static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, const char *level, const char *primary,
|
static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, const char *level, const char *primary,
|
||||||
const char *disable, ECfgSrcType stype) {
|
const char *disable, ECfgSrcType stype) {
|
||||||
|
int32_t code = 0;
|
||||||
(void)taosThreadMutexLock(&pCfg->lock);
|
(void)taosThreadMutexLock(&pCfg->lock);
|
||||||
|
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, name);
|
SConfigItem *pItem = cfgGetItem(pCfg, name);
|
||||||
|
@ -278,9 +281,21 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value,
|
||||||
|
|
||||||
SDiskCfg cfg = {0};
|
SDiskCfg cfg = {0};
|
||||||
tstrncpy(cfg.dir, pItem->str, sizeof(cfg.dir));
|
tstrncpy(cfg.dir, pItem->str, sizeof(cfg.dir));
|
||||||
cfg.level = level ? atoi(level) : 0;
|
|
||||||
cfg.primary = primary ? atoi(primary) : 1;
|
code = taosStr2int32(level, &cfg.level);
|
||||||
cfg.disable = disable ? atoi(disable) : 0;
|
if (code != 0) {
|
||||||
|
cfg.level = 0;
|
||||||
|
}
|
||||||
|
code = taosStr2int32(primary, &cfg.primary);
|
||||||
|
if (code != 0) {
|
||||||
|
cfg.primary = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = taosStr2int8(primary, &cfg.disable);
|
||||||
|
if (code != 0) {
|
||||||
|
cfg.disable = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void *ret = taosArrayPush(pItem->array, &cfg);
|
void *ret = taosArrayPush(pItem->array, &cfg);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
@ -412,6 +427,7 @@ void cfgLock(SConfig *pCfg) {
|
||||||
void cfgUnLock(SConfig *pCfg) { (void)taosThreadMutexUnlock(&pCfg->lock); }
|
void cfgUnLock(SConfig *pCfg) { (void)taosThreadMutexUnlock(&pCfg->lock); }
|
||||||
|
|
||||||
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer) {
|
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer) {
|
||||||
|
int32_t code = 0;
|
||||||
ECfgDynType dynType = isServer ? CFG_DYN_SERVER : CFG_DYN_CLIENT;
|
ECfgDynType dynType = isServer ? CFG_DYN_SERVER : CFG_DYN_CLIENT;
|
||||||
|
|
||||||
cfgLock(pCfg);
|
cfgLock(pCfg);
|
||||||
|
@ -443,8 +459,9 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case CFG_DTYPE_BOOL: {
|
case CFG_DTYPE_BOOL: {
|
||||||
int32_t ival = (int32_t)atoi(pVal);
|
int32_t ival = 0;
|
||||||
if (ival != 0 && ival != 1) {
|
code = taosStr2int32(pVal, &ival);
|
||||||
|
if (code != 0 || (ival != 0 && ival != 1)) {
|
||||||
uError("cfg:%s, type:%s value:%d out of range[0, 1]", pItem->name, cfgDtypeStr(pItem->dtype), ival);
|
uError("cfg:%s, type:%s value:%d out of range[0, 1]", pItem->name, cfgDtypeStr(pItem->dtype), ival);
|
||||||
cfgUnLock(pCfg);
|
cfgUnLock(pCfg);
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
|
@ -887,9 +904,10 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
for (size_t j = 0; j < sz; ++j) {
|
for (size_t j = 0; j < sz; ++j) {
|
||||||
SDiskCfg *pCfg = taosArrayGet(pItem->array, j);
|
SDiskCfg *pCfg = taosArrayGet(pItem->array, j);
|
||||||
if (dump) {
|
if (dump) {
|
||||||
(void)printf("%s %s %s l:%d p:%d d:%"PRIi8"\n", src, name, pCfg->dir, pCfg->level, pCfg->primary, pCfg->disable);
|
(void)printf("%s %s %s l:%d p:%d d:%" PRIi8 "\n", src, name, pCfg->dir, pCfg->level, pCfg->primary,
|
||||||
|
pCfg->disable);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %s l:%d p:%d d:%"PRIi8, src, name, pCfg->dir, pCfg->level, pCfg->primary, pCfg->disable);
|
uInfo("%s %s %s l:%d p:%d d:%" PRIi8, src, name, pCfg->dir, pCfg->level, pCfg->primary, pCfg->disable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
|
||||||
int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) {
|
int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) {
|
||||||
|
int32_t code = 0;
|
||||||
if (vstr == NULL) {
|
if (vstr == NULL) {
|
||||||
return terrno = TSDB_CODE_INVALID_VERSION_STRING;
|
return terrno = TSDB_CODE_INVALID_VERSION_STRING;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +32,11 @@ int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) {
|
||||||
if (vstr[spos] != '.') {
|
if (vstr[spos] != '.') {
|
||||||
tmp[spos - tpos] = vstr[spos];
|
tmp[spos - tpos] = vstr[spos];
|
||||||
} else {
|
} else {
|
||||||
vnum[vpos] = atoi(tmp);
|
code = taosStr2int32(tmp, &vnum[vpos]);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
// vnum[vpos] = atoi(tmp);
|
||||||
memset(tmp, 0, sizeof(tmp));
|
memset(tmp, 0, sizeof(tmp));
|
||||||
vpos++;
|
vpos++;
|
||||||
tpos = spos + 1;
|
tpos = spos + 1;
|
||||||
|
@ -39,7 +44,10 @@ int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('\0' != tmp[0] && vpos < 4) {
|
if ('\0' != tmp[0] && vpos < 4) {
|
||||||
vnum[vpos] = atoi(tmp);
|
code = taosStr2int32(tmp, &vnum[vpos]);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vnum[0] <= 0) {
|
if (vnum[0] <= 0) {
|
||||||
|
|
Loading…
Reference in New Issue