summaryrefslogtreecommitdiff
path: root/src/ziplist.c
diff options
context:
space:
mode:
authorhuangzhw <huang_zhw@126.com>2020-12-24 17:58:43 +0800
committerGitHub <noreply@github.com>2020-12-24 11:58:43 +0200
commitc4b52fc7c9e77fb1f2719d2cb5b9977b90698721 (patch)
tree59f3c4be96b4159b04d1e6a8fd774bb3e6bd53d5 /src/ziplist.c
parente87c31de66482e83ac36857e500847bfe8c13574 (diff)
downloadredis-c4b52fc7c9e77fb1f2719d2cb5b9977b90698721.tar.gz
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>
Diffstat (limited to 'src/ziplist.c')
-rw-r--r--src/ziplist.c8
1 files 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;