@@ -176,7 +176,7 @@ bool add_response_set_del_meta(const void* key,
176176 uint64_t cas,
177177 const void * cookie) {
178178 (void )cookie;
179- const uint8_t * ext_bytes = reinterpret_cast <const uint8_t *> (ext);
179+ const auto * ext_bytes = reinterpret_cast <const uint8_t *>(ext);
180180 if (ext && extlen > 0 ) {
181181 uint64_t vb_uuid;
182182 uint64_t seqno;
@@ -201,7 +201,7 @@ bool add_response_ret_meta(const void* key,
201201 uint64_t cas,
202202 const void * cookie) {
203203 (void )cookie;
204- const uint8_t * ext_bytes = reinterpret_cast <const uint8_t *> (ext);
204+ const auto * ext_bytes = reinterpret_cast <const uint8_t *>(ext);
205205 if (ext && extlen == 16 ) {
206206 memcpy (&last_meta.flags , ext_bytes, 4 );
207207 memcpy (&last_meta.exptime , ext_bytes + 4 , 4 );
@@ -331,8 +331,7 @@ protocol_binary_request_header* createPacket(uint8_t opcode,
331331 uint32_t headerlen = sizeof (protocol_binary_request_header);
332332 pkt_raw = static_cast <char *>(cb_calloc (1 , headerlen + extlen + keylen + vallen + nmeta));
333333 cb_assert (pkt_raw);
334- protocol_binary_request_header *req =
335- (protocol_binary_request_header*)pkt_raw;
334+ auto * req = reinterpret_cast <protocol_binary_request_header*>(pkt_raw);
336335 req->request .opcode = opcode;
337336 req->request .keylen = htons (keylen);
338337 req->request .extlen = extlen;
@@ -363,9 +362,10 @@ protocol_binary_request_header* createPacket(uint8_t opcode,
363362}
364363
365364void createCheckpoint (EngineIface* h) {
366- protocol_binary_request_header *request = createPacket (PROTOCOL_BINARY_CMD_CREATE_CHECKPOINT);
367- check (h->unknown_command (nullptr , request, add_response) == ENGINE_SUCCESS,
368- " Failed to create a new checkpoint." );
365+ auto * request = createPacket (PROTOCOL_BINARY_CMD_CREATE_CHECKPOINT);
366+ checkeq (ENGINE_SUCCESS,
367+ h->unknown_command (nullptr , request, add_response),
368+ " Failed to create a new checkpoint." );
369369 cb_free (request);
370370}
371371
@@ -499,9 +499,9 @@ void del_with_meta(EngineIface* h,
499499 nmeta.data (),
500500 nmeta.size ());
501501
502- check (h-> unknown_command (cookie, pkt, add_response_set_del_meta) ==
503- ENGINE_SUCCESS ,
504- " Expected to be able to delete with meta" );
502+ checkeq (ENGINE_SUCCESS,
503+ h-> unknown_command (cookie, pkt, add_response_set_del_meta) ,
504+ " Expected to be able to delete with meta" );
505505 cb_free (pkt);
506506}
507507
@@ -703,10 +703,16 @@ ENGINE_ERROR_CODE observe_seqno(EngineIface* h, Vbid vb_id, uint64_t uuid) {
703703}
704704
705705void get_replica (EngineIface* h, const char * key, Vbid vbid) {
706- protocol_binary_request_header *pkt;
707- pkt = createPacket (PROTOCOL_BINARY_CMD_GET_REPLICA, vbid, 0 , NULL , 0 , key, strlen (key));
708- check (h->unknown_command (nullptr , pkt, add_response) == ENGINE_SUCCESS,
709- " Get Replica Failed" );
706+ auto * pkt = createPacket (PROTOCOL_BINARY_CMD_GET_REPLICA,
707+ vbid,
708+ 0 ,
709+ NULL ,
710+ 0 ,
711+ key,
712+ strlen (key));
713+ checkeq (ENGINE_SUCCESS,
714+ h->unknown_command (nullptr , pkt, add_response),
715+ " Get Replica Failed" );
710716 cb_free (pkt);
711717}
712718
@@ -715,19 +721,20 @@ protocol_binary_request_header* prepare_get_replica(EngineIface* h,
715721 bool makeinvalidkey) {
716722 Vbid id (0 );
717723 const char *key = " k0" ;
718- protocol_binary_request_header * pkt;
719- pkt = createPacket ( PROTOCOL_BINARY_CMD_GET_REPLICA, id, 0 , NULL , 0 , key, strlen (key));
724+ auto * pkt = createPacket (
725+ PROTOCOL_BINARY_CMD_GET_REPLICA, id, 0 , NULL , 0 , key, strlen (key));
720726
721727 if (!makeinvalidkey) {
722- check (store (h,
723- nullptr ,
724- OPERATION_SET,
725- key,
726- " replicadata" ,
727- nullptr ,
728- 0 ,
729- id) == ENGINE_SUCCESS,
730- " Get Replica Failed" );
728+ checkeq (ENGINE_SUCCESS,
729+ store (h,
730+ nullptr ,
731+ OPERATION_SET,
732+ key,
733+ " replicadata" ,
734+ nullptr ,
735+ 0 ,
736+ id),
737+ " Get Replica Failed" );
731738
732739 check (set_vbucket_state (h, id, state),
733740 " Failed to set vbucket active state, Get Replica Failed" );
@@ -786,8 +793,9 @@ bool get_all_vb_seqnos(EngineIface* h,
786793 pkt = createPacket (PROTOCOL_BINARY_CMD_GET_ALL_VB_SEQNOS);
787794 }
788795
789- check (h->unknown_command (cookie, pkt, add_response) == ENGINE_SUCCESS,
790- " Error in getting all vb info" );
796+ checkeq (ENGINE_SUCCESS,
797+ h->unknown_command (cookie, pkt, add_response),
798+ " Error in getting all vb info" );
791799
792800 cb_free (pkt);
793801 return last_status == cb::mcbp::Status::Success;
@@ -853,13 +861,22 @@ static void store_with_meta(EngineIface* h,
853861 blen += sizeof (uint16_t );
854862 }
855863
856- protocol_binary_request_header *pkt;
857- pkt = createPacket (cmd, vb, cas_for_store, ext.get (), blen, key, keylen,
858- val, vallen, datatype, nmeta.data (), nmeta.size ());
864+ auto * pkt = createPacket (cmd,
865+ vb,
866+ cas_for_store,
867+ ext.get (),
868+ blen,
869+ key,
870+ keylen,
871+ val,
872+ vallen,
873+ datatype,
874+ nmeta.data (),
875+ nmeta.size ());
859876
860- check (h-> unknown_command (cookie, pkt, add_response_set_del_meta) ==
861- ENGINE_SUCCESS ,
862- " Expected to be able to store with meta" );
877+ checkeq (ENGINE_SUCCESS,
878+ h-> unknown_command (cookie, pkt, add_response_set_del_meta) ,
879+ " Expected to be able to store with meta" );
863880 cb_free (pkt);
864881}
865882
@@ -1013,20 +1030,24 @@ ENGINE_ERROR_CODE del_ret_meta(EngineIface* h,
10131030}
10141031
10151032void disable_traffic (EngineIface* h) {
1016- protocol_binary_request_header *pkt = createPacket (PROTOCOL_BINARY_CMD_DISABLE_TRAFFIC);
1017- check (h->unknown_command (NULL , pkt, add_response) == ENGINE_SUCCESS,
1018- " Failed to send data traffic command to the server" );
1019- check (last_status == cb::mcbp::Status::Success,
1020- " Failed to disable data traffic" );
1033+ auto * pkt = createPacket (PROTOCOL_BINARY_CMD_DISABLE_TRAFFIC);
1034+ checkeq (ENGINE_SUCCESS,
1035+ h->unknown_command (NULL , pkt, add_response),
1036+ " Failed to send data traffic command to the server" );
1037+ checkeq (cb::mcbp::Status::Success,
1038+ last_status.load (),
1039+ " Failed to disable data traffic" );
10211040 cb_free (pkt);
10221041}
10231042
10241043void enable_traffic (EngineIface* h) {
1025- protocol_binary_request_header *pkt = createPacket (PROTOCOL_BINARY_CMD_ENABLE_TRAFFIC);
1026- check (h->unknown_command (NULL , pkt, add_response) == ENGINE_SUCCESS,
1027- " Failed to send data traffic command to the server" );
1028- check (last_status == cb::mcbp::Status::Success,
1029- " Failed to enable data traffic" );
1044+ auto * pkt = createPacket (PROTOCOL_BINARY_CMD_ENABLE_TRAFFIC);
1045+ checkeq (ENGINE_SUCCESS,
1046+ h->unknown_command (NULL , pkt, add_response),
1047+ " Failed to send data traffic command to the server" );
1048+ checkeq (cb::mcbp::Status::Success,
1049+ last_status.load (),
1050+ " Failed to enable data traffic" );
10301051 cb_free (pkt);
10311052}
10321053
@@ -1036,11 +1057,13 @@ void start_persistence(EngineIface* h) {
10361057 return ;
10371058 }
10381059
1039- protocol_binary_request_header *pkt = createPacket (PROTOCOL_BINARY_CMD_START_PERSISTENCE);
1040- check (h->unknown_command (nullptr , pkt, add_response) == ENGINE_SUCCESS,
1041- " Failed to stop persistence." );
1042- check (last_status == cb::mcbp::Status::Success,
1043- " Error starting persistence." );
1060+ auto * pkt = createPacket (PROTOCOL_BINARY_CMD_START_PERSISTENCE);
1061+ checkeq (ENGINE_SUCCESS,
1062+ h->unknown_command (nullptr , pkt, add_response),
1063+ " Failed to stop persistence." );
1064+ checkeq (cb::mcbp::Status::Success,
1065+ last_status.load (),
1066+ " Error starting persistence." );
10441067 cb_free (pkt);
10451068}
10461069
@@ -1058,11 +1081,13 @@ void stop_persistence(EngineIface* h) {
10581081 decayingSleep (&sleepTime);
10591082 }
10601083
1061- protocol_binary_request_header *pkt = createPacket (PROTOCOL_BINARY_CMD_STOP_PERSISTENCE);
1062- check (h->unknown_command (nullptr , pkt, add_response) == ENGINE_SUCCESS,
1063- " Failed to stop persistence." );
1064- check (last_status == cb::mcbp::Status::Success,
1065- " Error stopping persistence." );
1084+ auto * pkt = createPacket (PROTOCOL_BINARY_CMD_STOP_PERSISTENCE);
1085+ checkeq (ENGINE_SUCCESS,
1086+ h->unknown_command (nullptr , pkt, add_response),
1087+ " Failed to stop persistence." );
1088+ checkeq (cb::mcbp::Status::Success,
1089+ last_status.load (),
1090+ " Error stopping persistence." );
10661091 cb_free (pkt);
10671092}
10681093
@@ -1232,8 +1257,9 @@ void compact_db(EngineIface* h,
12321257 0 ,
12331258 NULL ,
12341259 0 );
1235- check (h->unknown_command (NULL , pkt, add_response) == ENGINE_SUCCESS,
1236- " Failed to request compact vbucket" );
1260+ checkeq (ENGINE_SUCCESS,
1261+ h->unknown_command (NULL , pkt, add_response),
1262+ " Failed to request compact vbucket" );
12371263 cb_free (pkt);
12381264}
12391265
@@ -1283,8 +1309,9 @@ bool verify_vbucket_missing(EngineIface* h, Vbid vb) {
12831309 }
12841310
12851311 const auto * cookie = testHarness->create_cookie ();
1286- check (h->get_stats (cookie, {}, add_stats) == ENGINE_SUCCESS,
1287- " Failed to get stats." );
1312+ checkeq (ENGINE_SUCCESS,
1313+ h->get_stats (cookie, {}, add_stats),
1314+ " Failed to get stats." );
12881315 testHarness->destroy_cookie (cookie);
12891316
12901317 {
@@ -1519,8 +1546,6 @@ static void get_histo_stat(EngineIface* h,
15191546 if (err != ENGINE_SUCCESS) {
15201547 throw engine_error (err);
15211548 }
1522-
1523- return ;
15241549}
15251550
15261551statistic_map get_all_stats (EngineIface* h, const char * statset) {
@@ -1689,15 +1714,9 @@ void wait_for_persisted_value(EngineIface* h,
16891714 if (isPersistentBucket (h)) {
16901715 commitNum = get_int_stat (h, " ep_commit_num" );
16911716 }
1692- check (ENGINE_SUCCESS == store (h,
1693- NULL ,
1694- OPERATION_SET,
1695- key,
1696- val,
1697- nullptr ,
1698- 0 ,
1699- vbucketId),
1700- " Failed to store an item." );
1717+ checkeq (ENGINE_SUCCESS,
1718+ store (h, nullptr , OPERATION_SET, key, val, nullptr , 0 , vbucketId),
1719+ " Failed to store an item." );
17011720
17021721 if (isPersistentBucket (h)) {
17031722 // Wait for persistence...
0 commit comments