提交 2241cf06 编写于 作者: S Shengliang Guan

[TD-543] fix erro in coverity scan

上级 b0341310
...@@ -65,3 +65,4 @@ CMakeError.log ...@@ -65,3 +65,4 @@ CMakeError.log
/out/isenseconfig/WSL-GCC-Debug /out/isenseconfig/WSL-GCC-Debug
/test/cfg /test/cfg
/src/.vs /src/.vs
*.o
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
void * tsAcctSdb = NULL; void * tsAcctSdb = NULL;
static int32_t tsAcctUpdateSize; static int32_t tsAcctUpdateSize;
static void mnodeCreateRootAcct(); static int32_t mnodeCreateRootAcct();
static int32_t mnodeAcctActionDestroy(SSdbOper *pOper) { static int32_t mnodeAcctActionDestroy(SSdbOper *pOper) {
SAcctObj *pAcct = pOper->pObj; SAcctObj *pAcct = pOper->pObj;
...@@ -79,7 +79,11 @@ static int32_t mnodeAcctActionDecode(SSdbOper *pOper) { ...@@ -79,7 +79,11 @@ static int32_t mnodeAcctActionDecode(SSdbOper *pOper) {
static int32_t mnodeAcctActionRestored() { static int32_t mnodeAcctActionRestored() {
if (dnodeIsFirstDeploy()) { if (dnodeIsFirstDeploy()) {
mnodeCreateRootAcct(); int32_t code = mnodeCreateRootAcct();
if (code != TSDB_CODE_SUCCESS) {
mError("failed to create root account, reason:%s", tstrerror(code));
return code;
}
} }
acctInit(); acctInit();
...@@ -161,9 +165,9 @@ void mnodeDropUserFromAcct(SAcctObj *pAcct, SUserObj *pUser) { ...@@ -161,9 +165,9 @@ void mnodeDropUserFromAcct(SAcctObj *pAcct, SUserObj *pUser) {
mnodeDecAcctRef(pAcct); mnodeDecAcctRef(pAcct);
} }
static void mnodeCreateRootAcct() { static int32_t mnodeCreateRootAcct() {
int32_t numOfAccts = sdbGetNumOfRows(tsAcctSdb); int32_t numOfAccts = sdbGetNumOfRows(tsAcctSdb);
if (numOfAccts != 0) return; if (numOfAccts != 0) return TSDB_CODE_SUCCESS;
SAcctObj *pAcct = malloc(sizeof(SAcctObj)); SAcctObj *pAcct = malloc(sizeof(SAcctObj));
memset(pAcct, 0, sizeof(SAcctObj)); memset(pAcct, 0, sizeof(SAcctObj));
...@@ -190,7 +194,8 @@ static void mnodeCreateRootAcct() { ...@@ -190,7 +194,8 @@ static void mnodeCreateRootAcct() {
.table = tsAcctSdb, .table = tsAcctSdb,
.pObj = pAcct, .pObj = pAcct,
}; };
sdbInsertRow(&oper);
return sdbInsertRow(&oper);
} }
#ifndef _ACCT #ifndef _ACCT
......
...@@ -88,9 +88,9 @@ int32_t mnodeStartSystem() { ...@@ -88,9 +88,9 @@ int32_t mnodeStartSystem() {
} }
mPrint("starting to initialize mnode ..."); mPrint("starting to initialize mnode ...");
struct stat dirstat; if (mkdir(tsMnodeDir, 0755) != 0 && errno != EEXIST) {
if (stat(tsMnodeDir, &dirstat) < 0) { mError("failed to init mnode dir:%s, reason:%s", tsMnodeDir, strerror(errno));
mkdir(tsMnodeDir, 0755); return -1;
} }
dnodeAllocateMnodeWqueue(); dnodeAllocateMnodeWqueue();
......
...@@ -316,7 +316,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) { ...@@ -316,7 +316,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
} }
sprintf(pConnectRsp->acctId, "%x", pAcct->acctId); sprintf(pConnectRsp->acctId, "%x", pAcct->acctId);
strcpy(pConnectRsp->serverVersion, version); memcpy(pConnectRsp->serverVersion, version, TSDB_VERSION_LEN);
pConnectRsp->writeAuth = pUser->writeAuth; pConnectRsp->writeAuth = pUser->writeAuth;
pConnectRsp->superAuth = pUser->superAuth; pConnectRsp->superAuth = pUser->superAuth;
......
...@@ -75,19 +75,29 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { ...@@ -75,19 +75,29 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
mkdir(tsVnodeDir, 0755); if (mkdir(tsVnodeDir, 0755) != 0 && errno != EEXIST) {
vError("vgId:%d, failed to create vnode, reason:%s dir:%s", pVnodeCfg->cfg.vgId, strerror(errno), tsVnodeDir);
if (errno == EACCES) {
return TSDB_CODE_VND_NO_DISK_PERMISSIONS;
} else if (errno == ENOSPC) {
return TSDB_CODE_VND_NO_DISKSPACE;
} else if (errno == ENOENT) {
return TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR;
} else {
return TSDB_CODE_VND_INIT_FAILED;
}
}
char rootDir[TSDB_FILENAME_LEN] = {0}; char rootDir[TSDB_FILENAME_LEN] = {0};
sprintf(rootDir, "%s/vnode%d", tsVnodeDir, pVnodeCfg->cfg.vgId); sprintf(rootDir, "%s/vnode%d", tsVnodeDir, pVnodeCfg->cfg.vgId);
if (mkdir(rootDir, 0755) != 0) { if (mkdir(rootDir, 0755) != 0 && errno != EEXIST) {
vPrint("vgId:%d, failed to create vnode, reason:%s dir:%s", pVnodeCfg->cfg.vgId, strerror(errno), rootDir); vError("vgId:%d, failed to create vnode, reason:%s dir:%s", pVnodeCfg->cfg.vgId, strerror(errno), rootDir);
if (errno == EACCES) { if (errno == EACCES) {
return TSDB_CODE_VND_NO_DISK_PERMISSIONS; return TSDB_CODE_VND_NO_DISK_PERMISSIONS;
} else if (errno == ENOSPC) { } else if (errno == ENOSPC) {
return TSDB_CODE_VND_NO_DISKSPACE; return TSDB_CODE_VND_NO_DISKSPACE;
} else if (errno == ENOENT) { } else if (errno == ENOENT) {
return TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR; return TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR;
} else if (errno == EEXIST) {
} else { } else {
return TSDB_CODE_VND_INIT_FAILED; return TSDB_CODE_VND_INIT_FAILED;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册