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 <oran@redislabs.com>
This commit is contained in:
huangzhw 2020-12-24 17:58:43 +08:00 committed by GitHub
parent e87c31de66
commit c4b52fc7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;