From 4ee6c822cf81fab09a680dbc4b4bbad12bde4638 Mon Sep 17 00:00:00 2001 From: stephenkgu Date: Sun, 6 Dec 2020 12:04:36 +0800 Subject: [PATCH] use size_t instead of int32_t to avoid possible loss of data --- src/common/inc/tname.h | 2 +- src/common/src/tname.c | 2 +- src/mnode/src/mnodeTable.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/inc/tname.h b/src/common/inc/tname.h index 213aef1bd8..5c2948db76 100644 --- a/src/common/inc/tname.h +++ b/src/common/inc/tname.h @@ -25,7 +25,7 @@ void extractTableName(const char *tableId, char *name); char* extractDBName(const char *tableId, char *name); -int32_t tableIdPrefix(const char* pDb, char* prefix, int32_t len); +size_t tableIdPrefix(const char* pDb, char* prefix, int32_t len); void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable); diff --git a/src/common/src/tname.c b/src/common/src/tname.c index b86a0ad1d0..5c351edf48 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -39,7 +39,7 @@ char* extractDBName(const char* tableId, char* name) { return strncpy(name, &tableId[offset1 + 1], len); } -int32_t tableIdPrefix(const char* name, char* prefix, int32_t len) { +size_t tableIdPrefix(const char* name, char* prefix, int32_t len) { tstrncpy(prefix, name, len); strcat(prefix, TS_PATH_DELIMITER); diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 1505f16812..ad50b4929c 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1736,7 +1736,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { STagData *pTagData = (STagData *)pCreate->schema; // it is a tag key char prefix[64] = {0}; - int32_t prefixLen = tableIdPrefix(pMsg->pDb->name, prefix, 64); + size_t prefixLen = tableIdPrefix(pMsg->pDb->name, prefix, 64); if (0 != strncasecmp(prefix, pTagData->name, prefixLen)) { mError("msg:%p, app:%p table:%s, corresponding super table:%s not in this db", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableId, pTagData->name); -- GitLab