@@ -225,9 +225,7 @@ static inline RdbRes onWriteNewCmdDbg(RdbxToResp *ctx) {
225
225
if (ctx -> debug .flags & RFLAG_ENUM_CMD_ID ) {
226
226
char keyLenStr [32 ], cmdIdLenStr [32 ], cmdIdStr [32 ];
227
227
228
- RdbxRespWriterStartCmd startCmd ;
229
- startCmd .cmd = "SET" ;
230
- startCmd .key = KEY_CMD_ID_DBG ;
228
+ RdbxRespWriterStartCmd startCmd = {"SET" , KEY_CMD_ID_DBG , 0 };
231
229
232
230
struct iovec iov [7 ];
233
231
/* write SET */
@@ -296,9 +294,7 @@ static inline RdbRes sendFirstRestoreFrag(RdbxToResp *ctx, RdbBulk frag, size_t
296
294
if (ctx -> keyCtx .delBeforeWrite == DEL_KEY_BEFORE_BY_RESTORE_REPLACE )
297
295
extra_args ++ ;
298
296
299
- RdbxRespWriterStartCmd startCmd ;
300
- startCmd .cmd = "RESTORE" ;
301
- startCmd .key = ctx -> keyCtx .key ;
297
+ RdbxRespWriterStartCmd startCmd = {"RESTORE" , ctx -> keyCtx .key , ctx -> restoreCtx .restoreSize };
302
298
303
299
/* writev RESTORE */
304
300
char cmd [64 ];
@@ -326,9 +322,7 @@ static inline RdbRes sendFirstRestoreFragModuleAux(RdbxToResp *ctx, RdbBulk frag
326
322
struct iovec iov [3 ];
327
323
char lenStr [32 ];
328
324
329
- RdbxRespWriterStartCmd startCmd ;
330
- startCmd .cmd = "RESTOREMODAUX" ;
331
- startCmd .key = "" ;
325
+ RdbxRespWriterStartCmd startCmd = {"RESTOREMODAUX" , "" , ctx -> restoreCtx .restoreSize };
332
326
333
327
/* writev RESTOREMODAUX */
334
328
iov [0 ].iov_base = ctx -> restoreCtx .moduleAux .cmdPrefix ;
@@ -354,9 +348,7 @@ static RdbRes toRespNewDb(RdbParser *p, void *userData, int dbid) {
354
348
355
349
int cnt = ll2string (dbidStr , sizeof (dbidStr ), dbid );
356
350
357
- RdbxRespWriterStartCmd startCmd ;
358
- startCmd .cmd = "SELECT" ;
359
- startCmd .key = "" ;
351
+ RdbxRespWriterStartCmd startCmd = {"SELECT" , "" , 0 };
360
352
361
353
IOV_CONST (& iov [0 ], "*2\r\n$6\r\nSELECT" );
362
354
IOV_LENGTH (& iov [1 ], cnt , cntStr );
@@ -394,9 +386,7 @@ static RdbRes toRespNewKey(RdbParser *p, void *userData, RdbBulk key, RdbKeyInfo
394
386
struct iovec iov [4 ];
395
387
char keyLenStr [32 ];
396
388
397
- RdbxRespWriterStartCmd startCmd ;
398
- startCmd .cmd = "DEL" ;
399
- startCmd .key = ctx -> keyCtx .key ;
389
+ RdbxRespWriterStartCmd startCmd = {"DEL" , ctx -> keyCtx .key , 0 };
400
390
401
391
IOV_CONST (& iov [0 ], "*2\r\n$3\r\nDEL" );
402
392
IOV_LENGTH (& iov [1 ], ctx -> keyCtx .keyLen , keyLenStr );
@@ -415,9 +405,7 @@ static RdbRes toRespEndKey(RdbParser *p, void *userData) {
415
405
/* key is in db. Set its expiration time */
416
406
if (ctx -> keyCtx .info .expiretime != -1 ) {
417
407
struct iovec iov [6 ];
418
- RdbxRespWriterStartCmd startCmd ;
419
- startCmd .cmd = "PEXPIREAT" ;
420
- startCmd .key = ctx -> keyCtx .key ;
408
+ RdbxRespWriterStartCmd startCmd = {"PEXPIREAT" , ctx -> keyCtx .key , 0 };
421
409
422
410
char keyLenStr [32 ], expireLenStr [32 ], expireStr [32 ];
423
411
/* PEXPIREAT */
@@ -448,9 +436,7 @@ static RdbRes toRespString(RdbParser *p, void *userData, RdbBulk string) {
448
436
449
437
struct iovec iov [7 ];
450
438
451
- RdbxRespWriterStartCmd startCmd ;
452
- startCmd .cmd = "SET" ;
453
- startCmd .key = ctx -> keyCtx .key ;
439
+ RdbxRespWriterStartCmd startCmd = {"SET" , ctx -> keyCtx .key , 0 };
454
440
455
441
/* write SET */
456
442
IOV_CONST (& iov [0 ], "*3\r\n$3\r\nSET" );
@@ -473,9 +459,7 @@ static RdbRes toRespList(RdbParser *p, void *userData, RdbBulk item) {
473
459
char keyLenStr [32 ], valLenStr [32 ];
474
460
int valLen = RDB_bulkLen (p , item );
475
461
476
- RdbxRespWriterStartCmd startCmd ;
477
- startCmd .cmd = "RPUSH" ;
478
- startCmd .key = ctx -> keyCtx .key ;
462
+ RdbxRespWriterStartCmd startCmd = {"RPUSH" , ctx -> keyCtx .key , 0 };
479
463
480
464
/* write RPUSH */
481
465
IOV_CONST (& iov [0 ], "*3\r\n$5\r\nRPUSH" );
@@ -500,9 +484,7 @@ static RdbRes toRespHash(RdbParser *p, void *userData, RdbBulk field, RdbBulk va
500
484
int fieldLen = RDB_bulkLen (p , field );
501
485
int valueLen = RDB_bulkLen (p , value );
502
486
503
- RdbxRespWriterStartCmd hsetCmd ;
504
- hsetCmd .cmd = "HSET" ;
505
- hsetCmd .key = ctx -> keyCtx .key ;
487
+ RdbxRespWriterStartCmd hsetCmd = {"HSET" , ctx -> keyCtx .key , 0 };
506
488
507
489
/* write RPUSH */
508
490
IOV_CONST (& iov [0 ], "*4\r\n$4\r\nHSET" );
@@ -520,9 +502,8 @@ static RdbRes toRespHash(RdbParser *p, void *userData, RdbBulk field, RdbBulk va
520
502
521
503
if (expireAt == -1 ) return RDB_OK ;
522
504
523
- RdbxRespWriterStartCmd hpexpireatCmd ;
524
- hpexpireatCmd .cmd = "HPEXPIREAT" ;
525
- hpexpireatCmd .key = ctx -> keyCtx .key ;
505
+ RdbxRespWriterStartCmd hpexpireatCmd = {"HPEXPIREAT" , ctx -> keyCtx .key , 0 };
506
+
526
507
/* write HPEXPIREAT */
527
508
IOV_CONST (& iov [0 ], "*6\r\n$10\r\nHPEXPIREAT" );
528
509
/* write key */
@@ -545,9 +526,7 @@ static RdbRes toRespSet(RdbParser *p, void *userData, RdbBulk member) {
545
526
546
527
int valLen = RDB_bulkLen (p , member );
547
528
548
- RdbxRespWriterStartCmd startCmd ;
549
- startCmd .cmd = "SADD" ;
550
- startCmd .key = ctx -> keyCtx .key ;
529
+ RdbxRespWriterStartCmd startCmd = {"SADD" , ctx -> keyCtx .key , 0 };
551
530
552
531
/* write RPUSH */
553
532
IOV_CONST (& iov [0 ], "*3\r\n$4\r\nSADD" );
@@ -568,9 +547,7 @@ static RdbRes toRespZset(RdbParser *p, void *userData, RdbBulk member, double sc
568
547
569
548
int valLen = RDB_bulkLen (p , member );
570
549
571
- RdbxRespWriterStartCmd startCmd ;
572
- startCmd .cmd = "ZADD" ;
573
- startCmd .key = ctx -> keyCtx .key ;
550
+ RdbxRespWriterStartCmd startCmd = {"ZADD" , ctx -> keyCtx .key , 0 };
574
551
575
552
/* write ZADD */
576
553
IOV_CONST (& iov [0 ], "*4\r\n$4\r\nZADD" );
@@ -615,9 +592,7 @@ static RdbRes toRespFunction(RdbParser *p, void *userData, RdbBulk func) {
615
592
616
593
int funcLen = RDB_bulkLen (p , func );
617
594
618
- RdbxRespWriterStartCmd startCmd ;
619
- startCmd .cmd = "FUNCTION" ;
620
- startCmd .key = "" ;
595
+ RdbxRespWriterStartCmd startCmd = {"FUNCTION" , "" , 0 };
621
596
622
597
if (ctx -> conf .funcLibReplaceIfExist )
623
598
IOV_CONST (& iov [0 ], "*4\r\n$8\r\nFUNCTION\r\n$4\r\nLOAD\r\n$7\r\nREPLACE" );
@@ -644,9 +619,7 @@ static RdbRes toRespStreamMetaData(RdbParser *p, void *userData, RdbStreamMeta *
644
619
* for the Stream type. (We don't use the MAXLEN 0 trick from aof.c
645
620
* because of Redis Enterprise CRDT compatibility issues - Can't XSETID "back") */
646
621
647
- RdbxRespWriterStartCmd startCmd ;
648
- startCmd .cmd = "XGROUP CREATE" ;
649
- startCmd .key = ctx -> keyCtx .key ;
622
+ RdbxRespWriterStartCmd startCmd = {"XGROUP CREATE" , ctx -> keyCtx .key , 0 };
650
623
651
624
IOV_CONST (& iov [0 ], "*6\r\n$6\r\nXGROUP\r\n$6\r\nCREATE" );
652
625
IOV_LENGTH (& iov [1 ], ctx -> keyCtx .keyLen , keyLenStr );
@@ -671,9 +644,7 @@ static RdbRes toRespStreamMetaData(RdbParser *p, void *userData, RdbStreamMeta *
671
644
int idLen = snprintf (idStr , sizeof (idStr ), "%lu-%lu" ,meta -> lastID .ms ,meta -> lastID .seq );
672
645
int maxDelEntryIdLen = snprintf (maxDelEntryId , sizeof (maxDelEntryId ), "%lu-%lu" , meta -> maxDelEntryID .ms , meta -> maxDelEntryID .seq );
673
646
674
- RdbxRespWriterStartCmd startCmd ;
675
- startCmd .cmd = "XSETID" ;
676
- startCmd .key = ctx -> keyCtx .key ;
647
+ RdbxRespWriterStartCmd startCmd = {"XSETID" , ctx -> keyCtx .key , 0 };
677
648
678
649
if ((ctx -> keyCtx .info .opcode >= _RDB_TYPE_STREAM_LISTPACKS_2 ) && (ctx -> targetRedisVerVal >= VER_VAL (7 , 0 ))) {
679
650
IOV_CONST (& iov [0 ], "*7\r\n$6\r\nXSETID" );
@@ -711,8 +682,7 @@ static RdbRes toRespStreamItem(RdbParser *p, void *userData, RdbStreamID *id, Rd
711
682
712
683
/* Start of (another) stream item? */
713
684
if ((ctx -> streamCtx .xaddStartEndCounter % 2 ) == 0 ) {
714
- startCmd .cmd = "XADD" ;
715
- startCmd .key = ctx -> keyCtx .key ;
685
+ startCmd = (RdbxRespWriterStartCmd ) {"XADD" , ctx -> keyCtx .key , 0 };
716
686
startCmdRef = & startCmd ;
717
687
718
688
/* writev XADD */
@@ -763,9 +733,7 @@ static RdbRes toRespStreamNewCGroup(RdbParser *p, void *userData, RdbBulk grpNam
763
733
764
734
int idLen = snprintf (idStr , sizeof (idStr ), "%lu-%lu" ,meta -> lastId .ms ,meta -> lastId .seq );
765
735
766
- RdbxRespWriterStartCmd startCmd ;
767
- startCmd .cmd = "XGROUP" ;
768
- startCmd .key = ctx -> keyCtx .key ;
736
+ RdbxRespWriterStartCmd startCmd = { "XGROUP" , ctx -> keyCtx .key , 0 };
769
737
770
738
/* writev XGROUP */
771
739
if ( (meta -> entriesRead >=0 ) && (ctx -> targetRedisVerVal >= VER_VAL (7 , 0 ))) {
@@ -845,9 +813,7 @@ static RdbRes toRespStreamConsumerPendingEntry(RdbParser *p, void *userData, Rdb
845
813
return (RdbRes ) RDBX_ERR_STREAM_INTEG_CHECK ;
846
814
}
847
815
848
- RdbxRespWriterStartCmd startCmd ;
849
- startCmd .cmd = "XCLAIM" ;
850
- startCmd .key = ctx -> keyCtx .key ;
816
+ RdbxRespWriterStartCmd startCmd = {"XCLAIM" , ctx -> keyCtx .key , 0 };
851
817
852
818
/* writev XCLAIM */
853
819
IOV_CONST (& iov [iovs ++ ], "*12\r\n$6\r\nXCLAIM" );
0 commit comments