mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Suppress division by zero warning
Coverity is optimistic that we might do thousands of hashes in less
than a microsecond.
/tests/bench/siphash.c: 54 in main()
48 count++;
49 }
50
51 isc_time_now_hires(&finish);
52
53 us = isc_time_microdiff(&finish, &start);
>>> CID 358309: Integer handling issues (DIVIDE_BY_ZERO)
>>> In expression "count * 1000UL / us", division by expression "us" which may be zero has undefined behavior.
54 printf("%f us wide-lower len %3zu, %7llu kh/s (%llx)\n",
55 (double)us / 1000000.0, len,
56 (unsigned long long)(count * 1000 / us),
57 (unsigned long long)sum);
58 }
59
This commit is contained in:
parent
61b3dcc086
commit
cf715d488b
1 changed files with 14 additions and 18 deletions
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#define SIZE (1024 * 1024)
|
||||
|
||||
#define KILOHASHES(count, us) ((us) == 0 ? 0.0 : ((count)*1000.0 / (us)))
|
||||
|
||||
int
|
||||
main(void) {
|
||||
static uint8_t bytes[SIZE];
|
||||
|
|
@ -51,9 +53,8 @@ main(void) {
|
|||
isc_time_now_hires(&finish);
|
||||
|
||||
us = isc_time_microdiff(&finish, &start);
|
||||
printf("%f us wide-lower len %3zu, %7llu kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len,
|
||||
(unsigned long long)(count * 1000 / us),
|
||||
printf("%f us wide-lower len %3zu, %7.0f kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len, KILOHASHES(count, us),
|
||||
(unsigned long long)sum);
|
||||
}
|
||||
|
||||
|
|
@ -76,9 +77,8 @@ main(void) {
|
|||
isc_time_now_hires(&finish);
|
||||
|
||||
us = isc_time_microdiff(&finish, &start);
|
||||
printf("%f us wide-icase len %3zu, %7llu kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len,
|
||||
(unsigned long long)(count * 1000 / us),
|
||||
printf("%f us wide-icase len %3zu, %7.0f kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len, KILOHASHES(count, us),
|
||||
(unsigned long long)sum);
|
||||
}
|
||||
for (size_t len = 256; len > 0; len = len * 4 / 5) {
|
||||
|
|
@ -100,9 +100,8 @@ main(void) {
|
|||
isc_time_now_hires(&finish);
|
||||
|
||||
us = isc_time_microdiff(&finish, &start);
|
||||
printf("%f us wide-bytes len %3zu, %7llu kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len,
|
||||
(unsigned long long)(count * 1000 / us),
|
||||
printf("%f us wide-bytes len %3zu, %7.0f kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len, KILOHASHES(count, us),
|
||||
(unsigned long long)sum);
|
||||
}
|
||||
|
||||
|
|
@ -126,9 +125,8 @@ main(void) {
|
|||
isc_time_now_hires(&finish);
|
||||
|
||||
us = isc_time_microdiff(&finish, &start);
|
||||
printf("%f us half-lower len %3zu, %7llu kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len,
|
||||
(unsigned long long)(count * 1000 / us),
|
||||
printf("%f us half-lower len %3zu, %7.0f kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len, KILOHASHES(count, us),
|
||||
(unsigned long long)sum);
|
||||
}
|
||||
|
||||
|
|
@ -151,9 +149,8 @@ main(void) {
|
|||
isc_time_now_hires(&finish);
|
||||
|
||||
us = isc_time_microdiff(&finish, &start);
|
||||
printf("%f us half-icase len %3zu, %7llu kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len,
|
||||
(unsigned long long)(count * 1000 / us),
|
||||
printf("%f us half-icase len %3zu, %7.0f kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len, KILOHASHES(count, us),
|
||||
(unsigned long long)sum);
|
||||
}
|
||||
|
||||
|
|
@ -176,9 +173,8 @@ main(void) {
|
|||
isc_time_now_hires(&finish);
|
||||
|
||||
us = isc_time_microdiff(&finish, &start);
|
||||
printf("%f us half-bytes len %3zu, %7llu kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len,
|
||||
(unsigned long long)(count * 1000 / us),
|
||||
printf("%f us half-bytes len %3zu, %7.0f kh/s (%llx)\n",
|
||||
(double)us / 1000000.0, len, KILOHASHES(count, us),
|
||||
(unsigned long long)sum);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue