Skip to content

Commit 430dc93

Browse files
committed
Muzzle -Wshift-count-overflow warning.
This involves the s |= s >> 32 business when size_t is 32 bits. Change roundup2() to use unsigned long long unconditionally. We can't use uint64_t because MSVC doesn't have it, but unsigned long long is 64 bits on all platforms we care about.
1 parent 2ee7064 commit 430dc93

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/cache/lru.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,14 @@ struct _hash {
114114
size_t size;
115115
};
116116

117-
static inline size_t roundup2(size_t s) {
117+
static inline unsigned long long roundup2(unsigned long long s) {
118118
s--;
119119
s |= s >> 1;
120120
s |= s >> 2;
121121
s |= s >> 4;
122122
s |= s >> 8;
123123
s |= s >> 16;
124-
if (sizeof(size_t) >= 8)
125-
s |= s >> 32;
124+
s |= s >> 32;
126125
s++;
127126
return s;
128127
}

src/cache/twoq.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,14 @@ struct _hash {
124124
size_t size;
125125
};
126126

127-
static inline size_t roundup2(size_t s) {
127+
static inline unsigned long long roundup2(unsigned long long s) {
128128
s--;
129129
s |= s >> 1;
130130
s |= s >> 2;
131131
s |= s >> 4;
132132
s |= s >> 8;
133133
s |= s >> 16;
134-
if (sizeof(size_t) >= 8)
135-
s |= s >> 32;
134+
s |= s >> 32;
136135
s++;
137136
return s;
138137
}

0 commit comments

Comments
 (0)