Skip to content

Commit

Permalink
FIX Upgrade checkCount to uint64_t to avoid precision loss warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
rentzsch committed Sep 8, 2021
1 parent 5a2a001 commit e3e0e2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stressdrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int main(int argc, const char *argv[]) {

uint16_t bufferBlocks = bufferSize / blockSize;
uint32_t checkFrequency = 1024 * 1024 * 1024 / blockSize;
uint32_t checkCount = (blockCount + bufferBlocks - 1) / checkFrequency;
uint64_t checkCount = (blockCount + bufferBlocks - 1) / checkFrequency;
uint8_t *checkDigests = malloc(checkCount * SHA_DIGEST_LENGTH);
if (checkDigests == NULL) {
perror("malloc() failed");
Expand Down Expand Up @@ -250,7 +250,7 @@ int main(int argc, const char *argv[]) {
PROGRESS_Update(&progress, blockIndex, blockSize);

if ((blockIndex + bufferBlocks) % checkFrequency == 0) {
uint32_t checkIndex = blockIndex / checkFrequency;
uint64_t checkIndex = blockIndex / checkFrequency;
SHA1_Final(checkDigests + checkIndex * SHA_DIGEST_LENGTH, &shaContext);
SHA1_Init(&shaContext);
}
Expand Down Expand Up @@ -285,7 +285,7 @@ int main(int argc, const char *argv[]) {
PROGRESS_Update(&progress, blockIndex, blockSize);

if ((blockIndex + bufferBlocks) % checkFrequency == 0) {
uint32_t checkIndex = blockIndex / checkFrequency;
uint64_t checkIndex = blockIndex / checkFrequency;
SHA1_Final(readShaDigest, &shaContext);
SHA1_Init(&shaContext);
if (bcmp(checkDigests + checkIndex * SHA_DIGEST_LENGTH, readShaDigest, SHA_DIGEST_LENGTH) != 0) {
Expand Down

0 comments on commit e3e0e2b

Please sign in to comment.