Fix overflow in redis-benchmark (#11102)

Fix overflow in redis-benchmark affecting latency measurements on 32bit builds.

If `long` is 4 bytes (typical on 32 bit systems), multiplication overflows.
Using `long long` will fix the issue as it is guaranteed to be at least 8 bytes. 

Also, I've added a change to reuse `ustime()` for `mstime()`.
This commit is contained in:
Ozan Tezcan 2022-08-11 15:28:16 +03:00 committed by GitHub
parent 44859a41ee
commit 99ebbee2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -229,19 +229,13 @@ static long long ustime(void) {
long long ust;
gettimeofday(&tv, NULL);
ust = ((long)tv.tv_sec)*1000000;
ust = ((long long)tv.tv_sec)*1000000;
ust += tv.tv_usec;
return ust;
}
static long long mstime(void) {
struct timeval tv;
long long mst;
gettimeofday(&tv, NULL);
mst = ((long long)tv.tv_sec)*1000;
mst += tv.tv_usec/1000;
return mst;
return ustime()/1000;
}
static uint64_t dictSdsHash(const void *key) {