From c79cc7e454558c9f52ccaf819e0da22e0e8d4f9d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 13 Oct 2022 14:06:27 +0800 Subject: [PATCH] more code format --- source/libs/sync/inc/syncIO.h | 8 ++--- source/libs/sync/inc/syncRaftStore.h | 6 ++-- source/libs/sync/inc/syncVoteMgr.h | 8 ++--- source/libs/sync/src/syncIO.c | 6 ++-- source/libs/sync/src/syncMain.c | 36 +++++++++---------- source/libs/sync/src/syncRaftStore.c | 2 +- source/libs/sync/src/syncSnapshot.c | 4 +-- source/libs/sync/src/syncVoteMgr.c | 4 +-- .../sync/test/syncAppendEntriesReplyTest.cpp | 4 +-- .../libs/sync/test/syncAppendEntriesTest.cpp | 4 +-- source/libs/sync/test/syncApplyMsgTest.cpp | 4 +-- .../sync/test/syncClientRequestBatchTest.cpp | 2 +- .../libs/sync/test/syncClientRequestTest.cpp | 4 +-- .../test/syncConfigChangeSnapshotTest.cpp | 2 +- .../libs/sync/test/syncConfigChangeTest.cpp | 2 +- source/libs/sync/test/syncEncodeTest.cpp | 8 ++--- .../libs/sync/test/syncHeartbeatReplyTest.cpp | 24 ++++++------- source/libs/sync/test/syncHeartbeatTest.cpp | 16 ++++----- source/libs/sync/test/syncIndexTest.cpp | 2 +- .../libs/sync/test/syncLeaderTransferTest.cpp | 4 +-- source/libs/sync/test/syncPingReplyTest.cpp | 6 ++-- source/libs/sync/test/syncPingTest.cpp | 6 ++-- .../libs/sync/test/syncRaftCfgIndexTest.cpp | 8 ++--- .../libs/sync/test/syncReconfigFinishTest.cpp | 4 +-- source/libs/sync/test/syncRefTest.cpp | 2 +- .../sync/test/syncRequestVoteReplyTest.cpp | 4 +-- source/libs/sync/test/syncRequestVoteTest.cpp | 4 +-- source/libs/sync/test/syncSnapshotRspTest.cpp | 4 +-- .../libs/sync/test/syncSnapshotSendTest.cpp | 4 +-- source/libs/sync/test/syncSnapshotTest.cpp | 4 +-- source/libs/sync/test/syncTimeoutTest.cpp | 6 ++-- source/libs/sync/test/syncWriteTest.cpp | 4 +-- tools/scripts/codeFormat.sh | 2 +- 33 files changed, 102 insertions(+), 106 deletions(-) diff --git a/source/libs/sync/inc/syncIO.h b/source/libs/sync/inc/syncIO.h index f3064e668d..68d2334101 100644 --- a/source/libs/sync/inc/syncIO.h +++ b/source/libs/sync/inc/syncIO.h @@ -29,15 +29,15 @@ extern "C" { #include "tqueue.h" #include "trpc.h" -#define TICK_Q_TIMER_MS 1000 +#define TICK_Q_TIMER_MS 1000 #define TICK_Ping_TIMER_MS 1000 typedef struct SSyncIO { STaosQueue *pMsgQ; - STaosQset * pQset; + STaosQset *pQset; TdThread consumerTid; - void * serverRpc; - void * clientRpc; + void *serverRpc; + void *clientRpc; SEpSet myAddr; SMsgCb msgcb; diff --git a/source/libs/sync/inc/syncRaftStore.h b/source/libs/sync/inc/syncRaftStore.h index e0cbcf0744..ac298c5375 100644 --- a/source/libs/sync/inc/syncRaftStore.h +++ b/source/libs/sync/inc/syncRaftStore.h @@ -28,7 +28,7 @@ extern "C" { #include "taosdef.h" #define RAFT_STORE_BLOCK_SIZE 512 -#define RAFT_STORE_PATH_LEN (TSDB_FILENAME_LEN * 2) +#define RAFT_STORE_PATH_LEN (TSDB_FILENAME_LEN * 2) typedef struct SRaftStore { SyncTerm currentTerm; @@ -49,8 +49,8 @@ void raftStoreClearVote(SRaftStore *pRaftStore); void raftStoreNextTerm(SRaftStore *pRaftStore); void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson); -cJSON * raftStore2Json(SRaftStore *pRaftStore); -char * raftStore2Str(SRaftStore *pRaftStore); +cJSON *raftStore2Json(SRaftStore *pRaftStore); +char *raftStore2Str(SRaftStore *pRaftStore); // for debug ------------------- void raftStorePrint(SRaftStore *pObj); diff --git a/source/libs/sync/inc/syncVoteMgr.h b/source/libs/sync/inc/syncVoteMgr.h index 716d2f620c..aa245ce32c 100644 --- a/source/libs/sync/inc/syncVoteMgr.h +++ b/source/libs/sync/inc/syncVoteMgr.h @@ -46,8 +46,8 @@ void voteGrantedUpdate(SVotesGranted *pVotesGranted, SSyncNode *pSyncN bool voteGrantedMajority(SVotesGranted *pVotesGranted); void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg); void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term); -cJSON * voteGranted2Json(SVotesGranted *pVotesGranted); -char * voteGranted2Str(SVotesGranted *pVotesGranted); +cJSON *voteGranted2Json(SVotesGranted *pVotesGranted); +char *voteGranted2Str(SVotesGranted *pVotesGranted); // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj); @@ -70,8 +70,8 @@ void votesRespondUpdate(SVotesRespond *pVotesRespond, SSyncNode *pSync bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId); void votesRespondAdd(SVotesRespond *pVotesRespond, const SyncRequestVoteReply *pMsg); void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term); -cJSON * votesRespond2Json(SVotesRespond *pVotesRespond); -char * votesRespond2Str(SVotesRespond *pVotesRespond); +cJSON *votesRespond2Json(SVotesRespond *pVotesRespond); +char *votesRespond2Str(SVotesRespond *pVotesRespond); // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj); diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index b00be6edb6..e9899a3e33 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -30,7 +30,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void * syncIOConsumerFunc(void *param); +static void *syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -242,9 +242,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO * io = param; + SSyncIO *io = param; STaosQall *qall = taosAllocateQall(); - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; SQueueInfo qinfo = {0}; while (1) { diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 76fd345bdd..378ac743b3 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -52,9 +52,9 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); // --------------------------------- -static void syncNodeFreeCb(void *param) { - syncNodeClose(param); - param = NULL; +static void syncNodeFreeCb(void* param) { + syncNodeClose(param); + param = NULL; } int32_t syncInit() { @@ -947,15 +947,15 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { meta.batchSize = pSyncInfo->batchSize; ret = raftCfgCreateFile((SSyncCfg*)&(pSyncInfo->syncCfg), meta, pSyncNode->configPath); if (ret != 0) { - sError("failed to create raft cfg file. configPath: %s", pSyncNode->configPath); - goto _error; + sError("failed to create raft cfg file. configPath: %s", pSyncNode->configPath); + goto _error; } } else { // update syncCfg by raft_config.json pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); if (pSyncNode->pRaftCfg == NULL) { - sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); - goto _error; + sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); + goto _error; } pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; @@ -985,8 +985,8 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { // init internal pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; if (!syncUtilnodeInfo2raftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) { - sError("failed to determine my raft member id. vgId:%d", pSyncNode->vgId); - goto _error; + sError("failed to determine my raft member id. vgId:%d", pSyncNode->vgId); + goto _error; } // init peersNum, peers, peersId @@ -1000,17 +1000,17 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { } for (int i = 0; i < pSyncNode->peersNum; ++i) { if (!syncUtilnodeInfo2raftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])) { - sError("failed to determine raft member id. vgId:%d, peer:%d", pSyncNode->vgId, i); - goto _error; + sError("failed to determine raft member id. vgId:%d, peer:%d", pSyncNode->vgId, i); + goto _error; } } // init replicaNum, replicasId pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; for (int i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if(!syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { - sError("failed to determine raft member id. vgId:%d, replica:%d", pSyncNode->vgId, i); - goto _error; + if (!syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { + sError("failed to determine raft member id. vgId:%d, replica:%d", pSyncNode->vgId, i); + goto _error; } } @@ -1090,8 +1090,8 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { SSnapshot snapshot = {0}; int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (code != 0) { - sError("failed to get snapshot info. vgId:%d, code:%d", pSyncNode->vgId, code); - goto _error; + sError("failed to get snapshot info. vgId:%d, code:%d", pSyncNode->vgId, code); + goto _error; } if (snapshot.lastApplyIndex > commitIndex) { commitIndex = snapshot.lastApplyIndex; @@ -1191,8 +1191,8 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { _error: if (pSyncInfo->pFsm) { - taosMemoryFree(pSyncInfo->pFsm); - pSyncInfo->pFsm = NULL; + taosMemoryFree(pSyncInfo->pFsm); + pSyncInfo->pFsm = NULL; } syncNodeClose(pSyncNode); pSyncNode = NULL; diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 22b47a2c45..6d4d54a9b1 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -218,7 +218,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { char *raftStore2Str(SRaftStore *pRaftStore) { cJSON *pJson = raftStore2Json(pRaftStore); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 68d81813ac..6167d41141 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -36,8 +36,8 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI if (condition) { pSender = taosMemoryMalloc(sizeof(SSyncSnapshotSender)); if (pSender == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; } memset(pSender, 0, sizeof(*pSender)); diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 641bb32d2d..09b79825d0 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -130,7 +130,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -259,7 +259,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/syncAppendEntriesReplyTest.cpp b/source/libs/sync/test/syncAppendEntriesReplyTest.cpp index 72d3fd5ef3..a5e96233c2 100644 --- a/source/libs/sync/test/syncAppendEntriesReplyTest.cpp +++ b/source/libs/sync/test/syncAppendEntriesReplyTest.cpp @@ -37,7 +37,7 @@ void test1() { void test2() { SyncAppendEntriesReply *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncAppendEntriesReplySerialize(pMsg, serialized, len); SyncAppendEntriesReply *pMsg2 = syncAppendEntriesReplyBuild(1000); syncAppendEntriesReplyDeserialize(serialized, len, pMsg2); @@ -52,7 +52,7 @@ void test2() { void test3() { SyncAppendEntriesReply *pMsg = createMsg(); uint32_t len; - char * serialized = syncAppendEntriesReplySerialize2(pMsg, &len); + char *serialized = syncAppendEntriesReplySerialize2(pMsg, &len); SyncAppendEntriesReply *pMsg2 = syncAppendEntriesReplyDeserialize2(serialized, len); syncAppendEntriesReplyLog2((char *)"test3: syncAppendEntriesReplySerialize3 -> syncAppendEntriesReplyDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncAppendEntriesTest.cpp b/source/libs/sync/test/syncAppendEntriesTest.cpp index 98b392274e..256c13e267 100644 --- a/source/libs/sync/test/syncAppendEntriesTest.cpp +++ b/source/libs/sync/test/syncAppendEntriesTest.cpp @@ -37,7 +37,7 @@ void test1() { void test2() { SyncAppendEntries *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncAppendEntriesSerialize(pMsg, serialized, len); SyncAppendEntries *pMsg2 = syncAppendEntriesBuild(pMsg->dataLen, 1000); syncAppendEntriesDeserialize(serialized, len, pMsg2); @@ -51,7 +51,7 @@ void test2() { void test3() { SyncAppendEntries *pMsg = createMsg(); uint32_t len; - char * serialized = syncAppendEntriesSerialize2(pMsg, &len); + char *serialized = syncAppendEntriesSerialize2(pMsg, &len); SyncAppendEntries *pMsg2 = syncAppendEntriesDeserialize2(serialized, len); syncAppendEntriesLog2((char *)"test3: syncAppendEntriesSerialize3 -> syncAppendEntriesDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncApplyMsgTest.cpp b/source/libs/sync/test/syncApplyMsgTest.cpp index 30019f71e5..9d5e7dd8e1 100644 --- a/source/libs/sync/test/syncApplyMsgTest.cpp +++ b/source/libs/sync/test/syncApplyMsgTest.cpp @@ -43,7 +43,7 @@ void test1() { void test2() { SyncApplyMsg *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncApplyMsgSerialize(pMsg, serialized, len); SyncApplyMsg *pMsg2 = syncApplyMsgBuild(pMsg->dataLen); syncApplyMsgDeserialize(serialized, len, pMsg2); @@ -57,7 +57,7 @@ void test2() { void test3() { SyncApplyMsg *pMsg = createMsg(); uint32_t len; - char * serialized = syncApplyMsgSerialize2(pMsg, &len); + char *serialized = syncApplyMsgSerialize2(pMsg, &len); SyncApplyMsg *pMsg2 = syncApplyMsgDeserialize2(serialized, len); syncApplyMsgLog2((char *)"test3: syncApplyMsgSerialize2 -> syncApplyMsgDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncClientRequestBatchTest.cpp b/source/libs/sync/test/syncClientRequestBatchTest.cpp index 84d037be01..5586b7a6ce 100644 --- a/source/libs/sync/test/syncClientRequestBatchTest.cpp +++ b/source/libs/sync/test/syncClientRequestBatchTest.cpp @@ -33,7 +33,7 @@ SyncClientRequestBatch *createMsg() { for (int32_t i = 0; i < 5; ++i) { SRpcMsg *pRpcMsg = createRpcMsg(i, 20); rpcMsgPArr[i] = pRpcMsg; - //taosMemoryFree(pRpcMsg); + // taosMemoryFree(pRpcMsg); } SRaftMeta raftArr[5]; diff --git a/source/libs/sync/test/syncClientRequestTest.cpp b/source/libs/sync/test/syncClientRequestTest.cpp index 9376aca91f..56e53cc1c9 100644 --- a/source/libs/sync/test/syncClientRequestTest.cpp +++ b/source/libs/sync/test/syncClientRequestTest.cpp @@ -35,7 +35,7 @@ void test1() { void test2() { SyncClientRequest *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncClientRequestSerialize(pMsg, serialized, len); SyncClientRequest *pMsg2 = syncClientRequestBuild(pMsg->dataLen); syncClientRequestDeserialize(serialized, len, pMsg2); @@ -49,7 +49,7 @@ void test2() { void test3() { SyncClientRequest *pMsg = createMsg(); uint32_t len; - char * serialized = syncClientRequestSerialize2(pMsg, &len); + char *serialized = syncClientRequestSerialize2(pMsg, &len); SyncClientRequest *pMsg2 = syncClientRequestDeserialize2(serialized, len); syncClientRequestLog2((char *)"test3: syncClientRequestSerialize3 -> syncClientRequestDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp index fbfc4cda8e..c523fbc1c3 100644 --- a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp +++ b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp @@ -149,7 +149,7 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) { sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term); } diff --git a/source/libs/sync/test/syncConfigChangeTest.cpp b/source/libs/sync/test/syncConfigChangeTest.cpp index cfab3b6ae3..c04ab9b000 100644 --- a/source/libs/sync/test/syncConfigChangeTest.cpp +++ b/source/libs/sync/test/syncConfigChangeTest.cpp @@ -80,7 +80,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) { sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term); } diff --git a/source/libs/sync/test/syncEncodeTest.cpp b/source/libs/sync/test/syncEncodeTest.cpp index 454c823c6a..4016f07442 100644 --- a/source/libs/sync/test/syncEncodeTest.cpp +++ b/source/libs/sync/test/syncEncodeTest.cpp @@ -25,8 +25,8 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM * pFsm; -SWal * pWal; +SSyncFSM *pFsm; +SWal *pWal; SSyncNode *pSyncNode; SSyncNode *syncNodeInit() { @@ -187,8 +187,8 @@ int main(int argc, char **argv) { // step5 uint32_t len; - char * pMsg5 = step5(pMsg4, &len); - char * s = syncUtilprintBin(pMsg5, len); + char *pMsg5 = step5(pMsg4, &len); + char *s = syncUtilprintBin(pMsg5, len); printf("==step5== [%s] \n", s); taosMemoryFree(s); diff --git a/source/libs/sync/test/syncHeartbeatReplyTest.cpp b/source/libs/sync/test/syncHeartbeatReplyTest.cpp index 0ccd7b70bb..f5519fe6d4 100644 --- a/source/libs/sync/test/syncHeartbeatReplyTest.cpp +++ b/source/libs/sync/test/syncHeartbeatReplyTest.cpp @@ -35,13 +35,12 @@ void test1() { void test2() { SyncHeartbeatReply *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char *serialized = (char *)taosMemoryMalloc(len); syncHeartbeatReplySerialize(pMsg, serialized, len); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyBuild(1000); syncHeartbeatReplyDeserialize(serialized, len, pMsg2); - syncHeartbeatReplyLog2((char *)"test2: syncHeartbeatReplySerialize -> syncHeartbeatReplyDeserialize ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test2: syncHeartbeatReplySerialize -> syncHeartbeatReplyDeserialize ", pMsg2); taosMemoryFree(serialized); syncHeartbeatReplyDestroy(pMsg); @@ -50,11 +49,10 @@ void test2() { void test3() { SyncHeartbeatReply *pMsg = createMsg(); - uint32_t len; - char * serialized = syncHeartbeatReplySerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncHeartbeatReplySerialize2(pMsg, &len); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyDeserialize2(serialized, len); - syncHeartbeatReplyLog2((char *)"test3: syncHeartbeatReplySerialize3 -> syncHeartbeatReplyDeserialize2 ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test3: syncHeartbeatReplySerialize3 -> syncHeartbeatReplyDeserialize2 ", pMsg2); taosMemoryFree(serialized); syncHeartbeatReplyDestroy(pMsg); @@ -63,12 +61,11 @@ void test3() { void test4() { SyncHeartbeatReply *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeatReply2RpcMsg(pMsg, &rpcMsg); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyBuild(1000); syncHeartbeatReplyFromRpcMsg(&rpcMsg, pMsg2); - syncHeartbeatReplyLog2((char *)"test4: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test4: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg ", pMsg2); rpcFreeCont(rpcMsg.pCont); syncHeartbeatReplyDestroy(pMsg); @@ -77,11 +74,10 @@ void test4() { void test5() { SyncHeartbeatReply *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeatReply2RpcMsg(pMsg, &rpcMsg); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyFromRpcMsg2(&rpcMsg); - syncHeartbeatReplyLog2((char *)"test5: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg2 ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test5: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg2 ", pMsg2); rpcFreeCont(rpcMsg.pCont); syncHeartbeatReplyDestroy(pMsg); diff --git a/source/libs/sync/test/syncHeartbeatTest.cpp b/source/libs/sync/test/syncHeartbeatTest.cpp index d910c828f1..577af33b9c 100644 --- a/source/libs/sync/test/syncHeartbeatTest.cpp +++ b/source/libs/sync/test/syncHeartbeatTest.cpp @@ -19,7 +19,7 @@ SyncHeartbeat *createMsg() { pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234); pMsg->srcId.vgId = 100; pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678); - pMsg->destId.vgId = 100; + pMsg->destId.vgId = 100; pMsg->term = 8; pMsg->commitIndex = 33; pMsg->privateTerm = 44; @@ -34,8 +34,8 @@ void test1() { void test2() { SyncHeartbeat *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char *serialized = (char *)taosMemoryMalloc(len); syncHeartbeatSerialize(pMsg, serialized, len); SyncHeartbeat *pMsg2 = syncHeartbeatBuild(789); syncHeartbeatDeserialize(serialized, len, pMsg2); @@ -48,8 +48,8 @@ void test2() { void test3() { SyncHeartbeat *pMsg = createMsg(); - uint32_t len; - char * serialized = syncHeartbeatSerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncHeartbeatSerialize2(pMsg, &len); SyncHeartbeat *pMsg2 = syncHeartbeatDeserialize2(serialized, len); syncHeartbeatLog2((char *)"test3: syncHeartbeatSerialize2 -> syncHeartbeatDeserialize2 ", pMsg2); @@ -60,7 +60,7 @@ void test3() { void test4() { SyncHeartbeat *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeat2RpcMsg(pMsg, &rpcMsg); SyncHeartbeat *pMsg2 = (SyncHeartbeat *)taosMemoryMalloc(rpcMsg.contLen); syncHeartbeatFromRpcMsg(&rpcMsg, pMsg2); @@ -73,9 +73,9 @@ void test4() { void test5() { SyncHeartbeat *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeat2RpcMsg(pMsg, &rpcMsg); - SyncHeartbeat *pMsg2 =syncHeartbeatFromRpcMsg2(&rpcMsg); + SyncHeartbeat *pMsg2 = syncHeartbeatFromRpcMsg2(&rpcMsg); syncHeartbeatLog2((char *)"test5: syncHeartbeat2RpcMsg -> syncHeartbeatFromRpcMsg2 ", pMsg2); rpcFreeCont(rpcMsg.pCont); diff --git a/source/libs/sync/test/syncIndexTest.cpp b/source/libs/sync/test/syncIndexTest.cpp index 91c7800756..93cd5f79f0 100644 --- a/source/libs/sync/test/syncIndexTest.cpp +++ b/source/libs/sync/test/syncIndexTest.cpp @@ -9,7 +9,7 @@ void print(SHashObj *pNextIndex) { uint64_t *p = (uint64_t *)taosHashIterate(pNextIndex, NULL); while (p) { size_t len; - void * key = taosHashGetKey(p, &len); + void *key = taosHashGetKey(p, &len); SRaftId *pRaftId = (SRaftId *)key; diff --git a/source/libs/sync/test/syncLeaderTransferTest.cpp b/source/libs/sync/test/syncLeaderTransferTest.cpp index 1c3891d492..62a9106c15 100644 --- a/source/libs/sync/test/syncLeaderTransferTest.cpp +++ b/source/libs/sync/test/syncLeaderTransferTest.cpp @@ -36,7 +36,7 @@ void test1() { void test2() { SyncLeaderTransfer *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncLeaderTransferSerialize(pMsg, serialized, len); SyncLeaderTransfer *pMsg2 = syncLeaderTransferBuild(1000); syncLeaderTransferDeserialize(serialized, len, pMsg2); @@ -50,7 +50,7 @@ void test2() { void test3() { SyncLeaderTransfer *pMsg = createMsg(); uint32_t len; - char * serialized = syncLeaderTransferSerialize2(pMsg, &len); + char *serialized = syncLeaderTransferSerialize2(pMsg, &len); SyncLeaderTransfer *pMsg2 = syncLeaderTransferDeserialize2(serialized, len); syncLeaderTransferLog2((char *)"test3: syncLeaderTransferSerialize2 -> syncLeaderTransferDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncPingReplyTest.cpp b/source/libs/sync/test/syncPingReplyTest.cpp index 2bd8671e6c..e5158a7932 100644 --- a/source/libs/sync/test/syncPingReplyTest.cpp +++ b/source/libs/sync/test/syncPingReplyTest.cpp @@ -33,7 +33,7 @@ void test1() { void test2() { SyncPingReply *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncPingReplySerialize(pMsg, serialized, len); SyncPingReply *pMsg2 = syncPingReplyBuild(pMsg->dataLen); syncPingReplyDeserialize(serialized, len, pMsg2); @@ -47,7 +47,7 @@ void test2() { void test3() { SyncPingReply *pMsg = createMsg(); uint32_t len; - char * serialized = syncPingReplySerialize2(pMsg, &len); + char *serialized = syncPingReplySerialize2(pMsg, &len); SyncPingReply *pMsg2 = syncPingReplyDeserialize2(serialized, len); syncPingReplyLog2((char *)"test3: syncPingReplySerialize2 -> syncPingReplyDeserialize2 ", pMsg2); @@ -84,7 +84,7 @@ void test5() { void test6() { SyncPingReply *pMsg = createMsg(); int32_t bufLen = syncPingReplySerialize3(pMsg, NULL, 0); - char * serialized = (char *)taosMemoryMalloc(bufLen); + char *serialized = (char *)taosMemoryMalloc(bufLen); syncPingReplySerialize3(pMsg, serialized, bufLen); SyncPingReply *pMsg2 = syncPingReplyDeserialize3(serialized, bufLen); assert(pMsg2 != NULL); diff --git a/source/libs/sync/test/syncPingTest.cpp b/source/libs/sync/test/syncPingTest.cpp index a02f5e4b43..1777b9b9e2 100644 --- a/source/libs/sync/test/syncPingTest.cpp +++ b/source/libs/sync/test/syncPingTest.cpp @@ -33,7 +33,7 @@ void test1() { void test2() { SyncPing *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncPingSerialize(pMsg, serialized, len); SyncPing *pMsg2 = syncPingBuild(pMsg->dataLen); syncPingDeserialize(serialized, len, pMsg2); @@ -47,7 +47,7 @@ void test2() { void test3() { SyncPing *pMsg = createMsg(); uint32_t len; - char * serialized = syncPingSerialize2(pMsg, &len); + char *serialized = syncPingSerialize2(pMsg, &len); SyncPing *pMsg2 = syncPingDeserialize2(serialized, len); syncPingLog2((char *)"test3: syncPingSerialize2 -> syncPingDeserialize2 ", pMsg2); @@ -84,7 +84,7 @@ void test5() { void test6() { SyncPing *pMsg = createMsg(); int32_t bufLen = syncPingSerialize3(pMsg, NULL, 0); - char * serialized = (char *)taosMemoryMalloc(bufLen); + char *serialized = (char *)taosMemoryMalloc(bufLen); syncPingSerialize3(pMsg, serialized, bufLen); SyncPing *pMsg2 = syncPingDeserialize3(serialized, bufLen); assert(pMsg2 != NULL); diff --git a/source/libs/sync/test/syncRaftCfgIndexTest.cpp b/source/libs/sync/test/syncRaftCfgIndexTest.cpp index 6338383f92..bd8ffc45b6 100644 --- a/source/libs/sync/test/syncRaftCfgIndexTest.cpp +++ b/source/libs/sync/test/syncRaftCfgIndexTest.cpp @@ -53,20 +53,20 @@ SSyncCfg* createSyncCfg() { return pCfg; } -const char *pFile = "./raft_config_index.json"; +const char* pFile = "./raft_config_index.json"; void test1() { int32_t code = raftCfgIndexCreateFile(pFile); ASSERT(code == 0); - SRaftCfgIndex *pRaftCfgIndex = raftCfgIndexOpen(pFile); + SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); raftCfgIndexLog2((char*)"==test1==", pRaftCfgIndex); raftCfgIndexClose(pRaftCfgIndex); } void test2() { - SRaftCfgIndex *pRaftCfgIndex = raftCfgIndexOpen(pFile); + SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); for (int i = 0; i < 500; ++i) { raftCfgIndexAddConfigIndex(pRaftCfgIndex, i); } @@ -77,7 +77,7 @@ void test2() { } void test3() { - SRaftCfgIndex *pRaftCfgIndex = raftCfgIndexOpen(pFile); + SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); raftCfgIndexLog2((char*)"==test3==", pRaftCfgIndex); raftCfgIndexClose(pRaftCfgIndex); diff --git a/source/libs/sync/test/syncReconfigFinishTest.cpp b/source/libs/sync/test/syncReconfigFinishTest.cpp index 2aac38bbd1..5b283c5829 100644 --- a/source/libs/sync/test/syncReconfigFinishTest.cpp +++ b/source/libs/sync/test/syncReconfigFinishTest.cpp @@ -69,7 +69,7 @@ void test1() { void test2() { SyncReconfigFinish *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncReconfigFinishSerialize(pMsg, serialized, len); SyncReconfigFinish *pMsg2 = syncReconfigFinishBuild(1000); syncReconfigFinishDeserialize(serialized, len, pMsg2); @@ -83,7 +83,7 @@ void test2() { void test3() { SyncReconfigFinish *pMsg = createMsg(); uint32_t len; - char * serialized = syncReconfigFinishSerialize2(pMsg, &len); + char *serialized = syncReconfigFinishSerialize2(pMsg, &len); SyncReconfigFinish *pMsg2 = syncReconfigFinishDeserialize2(serialized, len); syncReconfigFinishLog2((char *)"test3: SyncReconfigFinishSerialize2 -> syncReconfigFinishDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncRefTest.cpp b/source/libs/sync/test/syncRefTest.cpp index 90923a87ee..c5132018a2 100644 --- a/source/libs/sync/test/syncRefTest.cpp +++ b/source/libs/sync/test/syncRefTest.cpp @@ -25,7 +25,7 @@ int g = 100; typedef struct SyncObj { int64_t rid; - void * data; + void *data; char name[32]; int counter; } SyncObj; diff --git a/source/libs/sync/test/syncRequestVoteReplyTest.cpp b/source/libs/sync/test/syncRequestVoteReplyTest.cpp index d9fe6fa011..3d9db17725 100644 --- a/source/libs/sync/test/syncRequestVoteReplyTest.cpp +++ b/source/libs/sync/test/syncRequestVoteReplyTest.cpp @@ -34,7 +34,7 @@ void test1() { void test2() { SyncRequestVoteReply *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncRequestVoteReplySerialize(pMsg, serialized, len); SyncRequestVoteReply *pMsg2 = syncRequestVoteReplyBuild(1000); syncRequestVoteReplyDeserialize(serialized, len, pMsg2); @@ -48,7 +48,7 @@ void test2() { void test3() { SyncRequestVoteReply *pMsg = createMsg(); uint32_t len; - char * serialized = syncRequestVoteReplySerialize2(pMsg, &len); + char *serialized = syncRequestVoteReplySerialize2(pMsg, &len); SyncRequestVoteReply *pMsg2 = syncRequestVoteReplyDeserialize2(serialized, len); syncRequestVoteReplyLog2((char *)"test3: syncRequestVoteReplySerialize3 -> syncRequestVoteReplyDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncRequestVoteTest.cpp b/source/libs/sync/test/syncRequestVoteTest.cpp index 4c6d7f94ad..94e1504add 100644 --- a/source/libs/sync/test/syncRequestVoteTest.cpp +++ b/source/libs/sync/test/syncRequestVoteTest.cpp @@ -35,7 +35,7 @@ void test1() { void test2() { SyncRequestVote *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncRequestVoteSerialize(pMsg, serialized, len); SyncRequestVote *pMsg2 = syncRequestVoteBuild(1000); syncRequestVoteDeserialize(serialized, len, pMsg2); @@ -49,7 +49,7 @@ void test2() { void test3() { SyncRequestVote *pMsg = createMsg(); uint32_t len; - char * serialized = syncRequestVoteSerialize2(pMsg, &len); + char *serialized = syncRequestVoteSerialize2(pMsg, &len); SyncRequestVote *pMsg2 = syncRequestVoteDeserialize2(serialized, len); syncRequestVoteLog2((char *)"test3: syncRequestVoteSerialize3 -> syncRequestVoteDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncSnapshotRspTest.cpp b/source/libs/sync/test/syncSnapshotRspTest.cpp index f689d47aaf..89348da617 100644 --- a/source/libs/sync/test/syncSnapshotRspTest.cpp +++ b/source/libs/sync/test/syncSnapshotRspTest.cpp @@ -38,7 +38,7 @@ void test1() { void test2() { SyncSnapshotRsp *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncSnapshotRspSerialize(pMsg, serialized, len); SyncSnapshotRsp *pMsg2 = syncSnapshotRspBuild(1000); syncSnapshotRspDeserialize(serialized, len, pMsg2); @@ -52,7 +52,7 @@ void test2() { void test3() { SyncSnapshotRsp *pMsg = createMsg(); uint32_t len; - char * serialized = syncSnapshotRspSerialize2(pMsg, &len); + char *serialized = syncSnapshotRspSerialize2(pMsg, &len); SyncSnapshotRsp *pMsg2 = syncSnapshotRspDeserialize2(serialized, len); syncSnapshotRspLog2((char *)"test3: syncSnapshotRspSerialize2 -> syncSnapshotRspDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncSnapshotSendTest.cpp b/source/libs/sync/test/syncSnapshotSendTest.cpp index ca7916359e..6fcfa6f6c4 100644 --- a/source/libs/sync/test/syncSnapshotSendTest.cpp +++ b/source/libs/sync/test/syncSnapshotSendTest.cpp @@ -48,7 +48,7 @@ void test1() { void test2() { SyncSnapshotSend *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncSnapshotSendSerialize(pMsg, serialized, len); SyncSnapshotSend *pMsg2 = syncSnapshotSendBuild(pMsg->dataLen, 1000); syncSnapshotSendDeserialize(serialized, len, pMsg2); @@ -62,7 +62,7 @@ void test2() { void test3() { SyncSnapshotSend *pMsg = createMsg(); uint32_t len; - char * serialized = syncSnapshotSendSerialize2(pMsg, &len); + char *serialized = syncSnapshotSendSerialize2(pMsg, &len); SyncSnapshotSend *pMsg2 = syncSnapshotSendDeserialize2(serialized, len); syncSnapshotSendLog2((char *)"test3: syncSnapshotSendSerialize2 -> syncSnapshotSendDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncSnapshotTest.cpp b/source/libs/sync/test/syncSnapshotTest.cpp index e0d33598b0..3dc8518072 100644 --- a/source/libs/sync/test/syncSnapshotTest.cpp +++ b/source/libs/sync/test/syncSnapshotTest.cpp @@ -25,8 +25,8 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM * pFsm; -SWal * pWal; +SSyncFSM *pFsm; +SWal *pWal; SSyncNode *gSyncNode; SyncIndex snapshotLastApplyIndex = SYNC_INDEX_INVALID; diff --git a/source/libs/sync/test/syncTimeoutTest.cpp b/source/libs/sync/test/syncTimeoutTest.cpp index e60fabe38b..bb0d71f003 100644 --- a/source/libs/sync/test/syncTimeoutTest.cpp +++ b/source/libs/sync/test/syncTimeoutTest.cpp @@ -30,7 +30,7 @@ void test1() { void test2() { SyncTimeout *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncTimeoutSerialize(pMsg, serialized, len); SyncTimeout *pMsg2 = syncTimeoutBuild(); syncTimeoutDeserialize(serialized, len, pMsg2); @@ -44,7 +44,7 @@ void test2() { void test3() { SyncTimeout *pMsg = createMsg(); uint32_t len; - char * serialized = syncTimeoutSerialize2(pMsg, &len); + char *serialized = syncTimeoutSerialize2(pMsg, &len); SyncTimeout *pMsg2 = syncTimeoutDeserialize2(serialized, len); syncTimeoutLog2((char *)"test3: syncTimeoutSerialize3 -> syncTimeoutDeserialize2 ", pMsg2); @@ -80,7 +80,7 @@ void test5() { void test6() { SyncTimeout *pMsg = createMsg(); - char * jsonStr = syncTimeout2Str(pMsg); + char *jsonStr = syncTimeout2Str(pMsg); sTrace("jsonStr: %s", jsonStr); syncUtilJson2Line(jsonStr); diff --git a/source/libs/sync/test/syncWriteTest.cpp b/source/libs/sync/test/syncWriteTest.cpp index 3bf068e3c7..b185f52f75 100644 --- a/source/libs/sync/test/syncWriteTest.cpp +++ b/source/libs/sync/test/syncWriteTest.cpp @@ -25,8 +25,8 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM * pFsm; -SWal * pWal; +SSyncFSM *pFsm; +SWal *pWal; SSyncNode *gSyncNode; const char *pDir = "./syncWriteTest"; diff --git a/tools/scripts/codeFormat.sh b/tools/scripts/codeFormat.sh index f45dce8a80..00f56d89f0 100644 --- a/tools/scripts/codeFormat.sh +++ b/tools/scripts/codeFormat.sh @@ -26,7 +26,7 @@ FORMAT_DIR_LIST=( # "${PRJ_ROOT_DIR}/source/libs/qworker" "${PRJ_ROOT_DIR}/source/libs/scalar" "${PRJ_ROOT_DIR}/source/libs/stream" - # "${PRJ_ROOT_DIR}/source/libs/sync" + "${PRJ_ROOT_DIR}/source/libs/sync" "${PRJ_ROOT_DIR}/source/libs/tdb" "${PRJ_ROOT_DIR}/source/libs/tfs" "${PRJ_ROOT_DIR}/source/libs/transport"