Skip to content

Commit

Permalink
Fix junk_data for 32-bit platforms
Browse files Browse the repository at this point in the history
Previously this had a mismatch between size_t and unsigned long long.
  • Loading branch information
gaul committed Aug 2, 2023
1 parent b29f8d0 commit c905abb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/junk_data.cc
Expand Up @@ -21,18 +21,19 @@
// Generate junk data at high speed. An alternative to dd if=/dev/urandom.

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

int main(int argc, const char *argv[])
{
if (argc != 2) {
return 1;
}
unsigned long long count = strtoull(argv[1], nullptr, 10);
uint64_t count = strtoull(argv[1], nullptr, 10);
char buf[128 * 1024];
for (size_t i = 0; i < count; i += sizeof(buf)) {
for (size_t j = 0; j < sizeof(buf) / sizeof(i); ++j) {
*(reinterpret_cast<long long *>(buf) + j) = i / sizeof(i) + j;
for (uint64_t i = 0; i < count; i += sizeof(buf)) {
for (uint64_t j = 0; j < sizeof(buf) / sizeof(i); ++j) {
*(reinterpret_cast<uint64_t *>(buf) + j) = i / sizeof(i) + j;
}
fwrite(buf, 1, sizeof(buf) > count - i ? count - i : sizeof(buf), stdout);
}
Expand Down

0 comments on commit c905abb

Please sign in to comment.