Merge pull request #17245 from taosdata/fix/TD-19245
fix: coverity issues
This commit is contained in:
commit
dccf33ec67
|
@ -94,6 +94,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
pCfgs = taosMemoryCalloc(vnodesNum, sizeof(SWrapperCfg));
|
pCfgs = taosMemoryCalloc(vnodesNum, sizeof(SWrapperCfg));
|
||||||
if (pCfgs == NULL) {
|
if (pCfgs == NULL) {
|
||||||
dError("failed to read %s since out of memory", file);
|
dError("failed to read %s since out of memory", file);
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +105,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
cJSON *vgId = cJSON_GetObjectItem(vnode, "vgId");
|
cJSON *vgId = cJSON_GetObjectItem(vnode, "vgId");
|
||||||
if (!vgId || vgId->type != cJSON_Number) {
|
if (!vgId || vgId->type != cJSON_Number) {
|
||||||
dError("failed to read %s since vgId not found", file);
|
dError("failed to read %s since vgId not found", file);
|
||||||
|
taosMemoryFree(pCfgs);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
pCfg->vgId = vgId->valueint;
|
pCfg->vgId = vgId->valueint;
|
||||||
|
@ -112,6 +114,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
cJSON *dropped = cJSON_GetObjectItem(vnode, "dropped");
|
cJSON *dropped = cJSON_GetObjectItem(vnode, "dropped");
|
||||||
if (!dropped || dropped->type != cJSON_Number) {
|
if (!dropped || dropped->type != cJSON_Number) {
|
||||||
dError("failed to read %s since dropped not found", file);
|
dError("failed to read %s since dropped not found", file);
|
||||||
|
taosMemoryFree(pCfgs);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
pCfg->dropped = dropped->valueint;
|
pCfg->dropped = dropped->valueint;
|
||||||
|
@ -119,6 +122,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
cJSON *vgVersion = cJSON_GetObjectItem(vnode, "vgVersion");
|
cJSON *vgVersion = cJSON_GetObjectItem(vnode, "vgVersion");
|
||||||
if (!vgVersion || vgVersion->type != cJSON_Number) {
|
if (!vgVersion || vgVersion->type != cJSON_Number) {
|
||||||
dError("failed to read %s since vgVersion not found", file);
|
dError("failed to read %s since vgVersion not found", file);
|
||||||
|
taosMemoryFree(pCfgs);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
pCfg->vgVersion = vgVersion->valueint;
|
pCfg->vgVersion = vgVersion->valueint;
|
||||||
|
@ -135,7 +139,6 @@ _OVER:
|
||||||
if (content != NULL) taosMemoryFree(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
if (code != 0) taosMemoryFree(pCfgs);
|
|
||||||
|
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
|
@ -143,8 +146,8 @@ _OVER:
|
||||||
|
|
||||||
int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
snprintf(file, sizeof(file), "%s%svnodes.json.bak", pMgmt->path, TD_DIRSEP);
|
snprintf(file, sizeof(file), "%s%svnodes.json.bak", pMgmt->path, TD_DIRSEP);
|
||||||
snprintf(realfile, sizeof(file), "%s%svnodes.json", pMgmt->path, TD_DIRSEP);
|
snprintf(realfile, sizeof(file), "%s%svnodes.json", pMgmt->path, TD_DIRSEP);
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc->ptype & DND_PROC_PARENT) {
|
if (proc->ptype & DND_PROC_PARENT) {
|
||||||
|
memset(ptr, 0, sizeof(SProcQueue));
|
||||||
if (dmInitProcMutex(queue) != 0) {
|
if (dmInitProcMutex(queue) != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -76,11 +77,11 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) {
|
||||||
tstrncpy(queue->name, proc->name, sizeof(queue->name));
|
tstrncpy(queue->name, proc->name, sizeof(queue->name));
|
||||||
|
|
||||||
taosThreadMutexLock(&queue->mutex);
|
taosThreadMutexLock(&queue->mutex);
|
||||||
queue->head = 0;
|
// queue->head = 0;
|
||||||
queue->tail = 0;
|
// queue->tail = 0;
|
||||||
queue->total = bufSize;
|
queue->total = bufSize;
|
||||||
queue->avail = bufSize;
|
queue->avail = bufSize;
|
||||||
queue->items = 0;
|
// queue->items = 0;
|
||||||
taosThreadMutexUnlock(&queue->mutex);
|
taosThreadMutexUnlock(&queue->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
||||||
dnodeObj.port = tsServerPort;
|
dnodeObj.port = tsServerPort;
|
||||||
tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||||
dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0;
|
dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0;
|
||||||
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
|
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
@ -490,7 +490,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
||||||
dnodeObj.updateTime = dnodeObj.createdTime;
|
dnodeObj.updateTime = dnodeObj.createdTime;
|
||||||
dnodeObj.port = pCreate->port;
|
dnodeObj.port = pCreate->port;
|
||||||
tstrncpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
|
tstrncpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
|
||||||
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
|
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", pCreate->fqdn, pCreate->port);
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
|
|
@ -22,6 +22,8 @@ int32_t tGenIdPI32(void) {
|
||||||
if (tUUIDHashId == 0) {
|
if (tUUIDHashId == 0) {
|
||||||
char uid[65] = {0};
|
char uid[65] = {0};
|
||||||
int32_t code = taosGetSystemUUID(uid, sizeof(uid));
|
int32_t code = taosGetSystemUUID(uid, sizeof(uid));
|
||||||
|
uid[64] = 0;
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue