Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off_t and size_t printf warnings on 32/64 bit systems. #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dieharder/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ void output(Dtest *dtest,Test **test)
if(strncmp("file_input",gsl_rng_name(rng),10) == 0){
if(tflag & TFILE_RNG_STAT) {
if(strncmp("file_input_raw",gsl_rng_name(rng),14) == 0){
fprintf(stdout,"# The %s %s %lu rands (%llu bytes) were used\n",
filename, gsl_rng_name(rng),file_input_get_rtot(rng),
fprintf(stdout,"# The %s %s %lld rands (%llu bytes) were used\n",
filename, gsl_rng_name(rng),(long long)file_input_get_rtot(rng),
(unsigned long long)file_input_get_rtot(rng) * sizeof(uint));
} else {
fprintf(stdout,"# The file %s %s %lu rands were used\n",
filename, gsl_rng_name(rng),file_input_get_rtot(rng));
fprintf(stdout,"# The file %s %s %lld rands were used\n",
filename, gsl_rng_name(rng),(long long)file_input_get_rtot(rng));
}
if(file_input_get_rewind_cnt(rng) == 0){
fprintf(stdout,"# The file %s was rewound %u times\n",
Expand Down
6 changes: 3 additions & 3 deletions dieharder/output_rnds.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void output_rnds()
FILE *fp;

if(verbose) {
fprintf(stderr,"# output_rnds: Dumping %lu rands\n",tsamples);
fprintf(stderr,"# output_rnds: Dumping %lld rands\n",(long long)tsamples);
}

/*
Expand Down Expand Up @@ -118,7 +118,7 @@ void output_rnds()
fprintf(fp,"#==================================================================\n");
fprintf(fp,"# generator %s seed = %lu\n",gsl_rng_name(rng),seed);
fprintf(fp,"#==================================================================\n");
fprintf(fp,"type: d\ncount: %lu\nnumbit: 32\n",tsamples);
fprintf(fp,"type: d\ncount: %lld\nnumbit: 32\n",(long long)tsamples);
for(i=0;i<tsamples;i++){
j = gsl_rng_get(rng);
fprintf(fp,"%10u\n",j);
Expand All @@ -128,7 +128,7 @@ void output_rnds()
fprintf(fp,"#==================================================================\n");
fprintf(fp,"# generator %s seed = %lu\n",gsl_rng_name(rng),seed);
fprintf(fp,"#==================================================================\n");
fprintf(fp,"type: f\ncount: %lu\nnumbit: 32\n",tsamples);
fprintf(fp,"type: f\ncount: %lld\nnumbit: 32\n",(long long)tsamples);
for(i=0;i<tsamples;i++){
d = gsl_rng_uniform(rng);
fprintf(fp,"%0.10f\n",d);
Expand Down
2 changes: 1 addition & 1 deletion libdieharder/bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ int get_int_bit(unsigned int i, unsigned int n)
* Note
*/
if(n < 0 || n > 8*sizeof(unsigned int)){
fprintf(stderr,"Error: bit offset %u exceeds length %lu of uint.\n",n,8*sizeof(unsigned int));
fprintf(stderr,"Error: bit offset %u exceeds length %zu of uint.\n",n,8*sizeof(unsigned int));
exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion libdieharder/countx.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main_countx( int argc, char **argv)
free(data);

time(&z);
printf("number of seconds: %6lu\n", (size_t)(z-a));
printf("number of seconds: %6zu\n", (size_t)(z-a));

return 0;

Expand Down
2 changes: 1 addition & 1 deletion libdieharder/rgb_permutations.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int rgb_permutations(Test **test,int irun)

MYDEBUG(D_RGB_PERMUTATIONS){
for(i=0;i<k;i++) {
printf("# rgb_permutations: ps[%u] = %lu\n",i,ps[i]);
printf("# rgb_permutations: ps[%u] = %zu\n",i,ps[i]);
}
}

Expand Down
11 changes: 7 additions & 4 deletions libdieharder/rng_file_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ static unsigned long int file_input_get (void *vstate)
state->rptr++;
state->rtot++;
if(verbose){
fprintf(stdout,"# file_input() %lu: %lu/%lu -> %u\n", state->rtot, state->rptr,state->flen,(uint)iret);
fprintf(stdout,"# file_input() %lld: %lld/%lld -> %u\n",
(long long)state->rtot, (long long)state->rptr, (long long)state->flen, (uint)iret);
}

/*
Expand Down Expand Up @@ -277,8 +278,10 @@ static void file_input_set (void *vstate, unsigned long int s)
state->rptr = 0;
state->rewind_cnt++;
if(verbose == D_FILE_INPUT || verbose == D_ALL){
fprintf(stderr,"# file_input(): Rewinding %s at rtot = %u\n", filename,(uint) state->rtot);
fprintf(stderr,"# file_input(): Rewind count = %u, resetting rptr = %lu\n",state->rewind_cnt,state->rptr);
fprintf(stderr,"# file_input(): Rewinding %s at rtot = %lld\n",
filename, (long long)state->rtot);
fprintf(stderr,"# file_input(): Rewind count = %u, resetting rptr = %lld\n",
state->rewind_cnt, (long long)state->rptr);
}
} else {
return;
Expand Down Expand Up @@ -330,7 +333,7 @@ static void file_input_set (void *vstate, unsigned long int s)
cnt++;
if(verbose){
fprintf(stdout,"# file_input(): cnt = %d\n",cnt);
fprintf(stdout,"# file_input(): state->flen set to %lu\n",state->flen);
fprintf(stdout,"# file_input(): state->flen set to %lld\n", (long long)state->flen);
}
}
if(strncmp(splitbuf[0],"numbit",6) == 0){
Expand Down
2 changes: 1 addition & 1 deletion libdieharder/rngav.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int main_rngav( int argc, char **argv)

time(&z);

printf("number of seconds: %6lu\n", (size_t)(z-a));
printf("number of seconds: %6zu\n", (size_t)(z-a));

return 0;

Expand Down
2 changes: 1 addition & 1 deletion libdieharder/sts_monobit.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int sts_monobit(Test **test, int irun)
* that if -b bits is specified, size will be "more than enough".
*/
MYDEBUG(D_STS_MONOBIT) {
printf("# rgb_bitdist(): Generating %lu bits in bitstring",test[0]->tsamples*sizeof(uint)*8);
printf("# rgb_bitdist(): Generating %zu bits in bitstring",test[0]->tsamples*sizeof(uint)*8);
}
ptest.x = 0;

Expand Down
Loading