Skip to content

Commit

Permalink
Count work_done in 64 bits to prevent overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wentasah committed Nov 20, 2020
1 parent fbc8f9e commit 9cc8e64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char** argv) {
int opt;
bool forever = false;
char *work_done_string = NULL;
unsigned work_done = 0;
unsigned long long work_done = 0;
int work_done_every = 1;

while ((opt = getopt(argc, argv, "e:fw:")) != -1) {
Expand Down Expand Up @@ -119,7 +119,7 @@ int main(int argc, char** argv) {
}
}
if (work_done_string && (work_done++ % work_done_every == 0)) {
printf("%s=%d\n", work_done_string, work_done - 1);
printf("%s=%lld\n", work_done_string, work_done - 1);
fflush(stdout);
}
} while (forever);
Expand Down

0 comments on commit 9cc8e64

Please sign in to comment.