fix integer overflow

This commit is contained in:
Xudong Zhang 2020-04-02 23:43:19 +08:00
parent 416d394cd9
commit 78df016584

View File

@ -110,7 +110,7 @@ quicklist *quicklistCreate(void) {
return quicklist; return quicklist;
} }
#define COMPRESS_MAX (1 << QL_COMP_BITS) #define COMPRESS_MAX ((1 << QL_COMP_BITS)-1)
void quicklistSetCompressDepth(quicklist *quicklist, int compress) { void quicklistSetCompressDepth(quicklist *quicklist, int compress) {
if (compress > COMPRESS_MAX) { if (compress > COMPRESS_MAX) {
compress = COMPRESS_MAX; compress = COMPRESS_MAX;
@ -120,7 +120,7 @@ void quicklistSetCompressDepth(quicklist *quicklist, int compress) {
quicklist->compress = compress; quicklist->compress = compress;
} }
#define FILL_MAX (1 << (QL_FILL_BITS-1)) #define FILL_MAX ((1 << (QL_FILL_BITS-1))-1)
void quicklistSetFill(quicklist *quicklist, int fill) { void quicklistSetFill(quicklist *quicklist, int fill) {
if (fill > FILL_MAX) { if (fill > FILL_MAX) {
fill = FILL_MAX; fill = FILL_MAX;