fix coverity scan bugs
This commit is contained in:
parent
775c5313d4
commit
8da1ff0274
|
@ -218,9 +218,9 @@ void *rpcOpen(const SRpcInit *pInit) {
|
||||||
pRpc->localPort = pInit->localPort;
|
pRpc->localPort = pInit->localPort;
|
||||||
pRpc->afp = pInit->afp;
|
pRpc->afp = pInit->afp;
|
||||||
pRpc->sessions = pInit->sessions+1;
|
pRpc->sessions = pInit->sessions+1;
|
||||||
if (pInit->user) strcpy(pRpc->user, pInit->user);
|
if (pInit->user) tstrncpy(pRpc->user, pInit->user, sizeof(pRpc->user));
|
||||||
if (pInit->secret) strcpy(pRpc->secret, pInit->secret);
|
if (pInit->secret) memcpy(pRpc->secret, pInit->secret, sizeof(pRpc->secret));
|
||||||
if (pInit->ckey) strcpy(pRpc->ckey, pInit->ckey);
|
if (pInit->ckey) tstrncpy(pRpc->ckey, pInit->ckey, sizeof(pRpc->ckey));
|
||||||
pRpc->spi = pInit->spi;
|
pRpc->spi = pInit->spi;
|
||||||
pRpc->cfp = pInit->cfp;
|
pRpc->cfp = pInit->cfp;
|
||||||
pRpc->afp = pInit->afp;
|
pRpc->afp = pInit->afp;
|
||||||
|
@ -435,6 +435,7 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
|
|
||||||
void rpcSendRedirectRsp(void *thandle, const SRpcIpSet *pIpSet) {
|
void rpcSendRedirectRsp(void *thandle, const SRpcIpSet *pIpSet) {
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg;
|
||||||
|
memset(&rpcMsg, 0, sizeof(rpcMsg));
|
||||||
|
|
||||||
rpcMsg.contLen = sizeof(SRpcIpSet);
|
rpcMsg.contLen = sizeof(SRpcIpSet);
|
||||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||||
|
|
|
@ -253,12 +253,14 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
|
||||||
|
|
||||||
if (pthread_mutex_init(&(pThreadObj->mutex), NULL) < 0) {
|
if (pthread_mutex_init(&(pThreadObj->mutex), NULL) < 0) {
|
||||||
tError("%s failed to init TCP client mutex(%s)", label, strerror(errno));
|
tError("%s failed to init TCP client mutex(%s)", label, strerror(errno));
|
||||||
|
free(pThreadObj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pThreadObj->pollFd = epoll_create(10); // size does not matter
|
pThreadObj->pollFd = epoll_create(10); // size does not matter
|
||||||
if (pThreadObj->pollFd < 0) {
|
if (pThreadObj->pollFd < 0) {
|
||||||
tError("%s failed to create TCP client epoll", label);
|
tError("%s failed to create TCP client epoll", label);
|
||||||
|
free(pThreadObj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +271,8 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
|
||||||
int code = pthread_create(&(pThreadObj->thread), &thattr, taosProcessTcpData, (void *)(pThreadObj));
|
int code = pthread_create(&(pThreadObj->thread), &thattr, taosProcessTcpData, (void *)(pThreadObj));
|
||||||
pthread_attr_destroy(&thattr);
|
pthread_attr_destroy(&thattr);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
close(pThreadObj->pollFd);
|
||||||
|
free(pThreadObj);
|
||||||
tError("%s failed to create TCP read data thread(%s)", label, strerror(errno));
|
tError("%s failed to create TCP read data thread(%s)", label, strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tutil.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "rpcLog.h"
|
#include "rpcLog.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
@ -105,7 +106,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||||
ipSet.port[0] = atoi(argv[++i]);
|
ipSet.port[0] = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
||||||
strcpy(ipSet.fqdn[0], argv[++i]);
|
tstrncpy(ipSet.fqdn[0], argv[++i], sizeof(ipSet.fqdn));
|
||||||
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
||||||
rpcInit.numOfThreads = atoi(argv[++i]);
|
rpcInit.numOfThreads = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tutil.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "rpcLog.h"
|
#include "rpcLog.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
@ -106,7 +107,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||||
ipSet.port[0] = atoi(argv[++i]);
|
ipSet.port[0] = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
||||||
strcpy(ipSet.fqdn[0], argv[++i]);
|
tstrncpy(ipSet.fqdn[0], argv[++i], sizeof(ipSet.fqdn));
|
||||||
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
||||||
rpcInit.numOfThreads = atoi(argv[++i]);
|
rpcInit.numOfThreads = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
||||||
|
|
|
@ -69,6 +69,7 @@ void processShellMsg() {
|
||||||
taosGetQitem(qall, &type, (void **)&pRpcMsg);
|
taosGetQitem(qall, &type, (void **)&pRpcMsg);
|
||||||
rpcFreeCont(pRpcMsg->pCont);
|
rpcFreeCont(pRpcMsg->pCont);
|
||||||
|
|
||||||
|
memset(&rpcMsg, 0, sizeof(rpcMsg));
|
||||||
rpcMsg.pCont = rpcMallocCont(msgSize);
|
rpcMsg.pCont = rpcMallocCont(msgSize);
|
||||||
rpcMsg.contLen = msgSize;
|
rpcMsg.contLen = msgSize;
|
||||||
rpcMsg.handle = pRpcMsg->handle;
|
rpcMsg.handle = pRpcMsg->handle;
|
||||||
|
|
|
@ -42,6 +42,11 @@ extern "C" {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define tstrncpy(dst, src, size) do { \
|
||||||
|
strncpy((dst), (src), (size)); \
|
||||||
|
(dst)[(size) - 1] = 0; \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
#define tclose(x) taosCloseSocket(x)
|
#define tclose(x) taosCloseSocket(x)
|
||||||
|
|
||||||
// Pointer p drift right by b bytes
|
// Pointer p drift right by b bytes
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
//#define _DEFAULT_SOURCE
|
//#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tutil.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "twal.h"
|
#include "twal.h"
|
||||||
|
@ -45,7 +46,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
for (int i=1; i<argc; ++i) {
|
for (int i=1; i<argc; ++i) {
|
||||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||||
strcpy(path, argv[++i]);
|
tstrncpy(path, argv[++i], sizeof(path));
|
||||||
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
||||||
max = atoi(argv[++i]);
|
max = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-l")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-l")==0 && i < argc-1) {
|
||||||
|
|
Loading…
Reference in New Issue