From bd08dbcf830014678808a8fef5fe39e4ab250fd0 Mon Sep 17 00:00:00 2001 From: huangzhw Date: Thu, 24 Dec 2020 17:58:43 +0800 Subject: [PATCH] cleanup: ziplist prev entry large length use sizeof(uint32_t) instead 4 (#8241) This is just a cleanup, no bugs in the real world. Co-authored-by: Oran Agra --- src/ziplist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ziplist.c b/src/ziplist.c index 866078613..96ba47e13 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -431,19 +431,21 @@ unsigned int zipStoreEntryEncoding(unsigned char *p, unsigned char encoding, uns /* Encode the length of the previous entry and write it to "p". This only * uses the larger encoding (required in __ziplistCascadeUpdate). */ int zipStorePrevEntryLengthLarge(unsigned char *p, unsigned int len) { + uint32_t u32; if (p != NULL) { p[0] = ZIP_BIG_PREVLEN; - memcpy(p+1,&len,sizeof(len)); + u32 = len; + memcpy(p+1,&u32,sizeof(u32)); memrev32ifbe(p+1); } - return 1+sizeof(len); + return 1 + sizeof(uint32_t); } /* Encode the length of the previous entry and write it to "p". Return the * number of bytes needed to encode this length if "p" is NULL. */ unsigned int zipStorePrevEntryLength(unsigned char *p, unsigned int len) { if (p == NULL) { - return (len < ZIP_BIG_PREVLEN) ? 1 : sizeof(len)+1; + return (len < ZIP_BIG_PREVLEN) ? 1 : sizeof(uint32_t) + 1; } else { if (len < ZIP_BIG_PREVLEN) { p[0] = len;