Skip to content

Commit

Permalink
In printf, use %d instead of %i
Browse files Browse the repository at this point in the history
Unusually, this commit includes changes to the Makefiles (generated via
`make Makefiles`); it didn't seem worth putting those in a separate
commit.
  • Loading branch information
gperciva committed Jan 26, 2024
1 parent 4511e76 commit 917ccb2
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ gotheaders(struct http_cookie * H, uint8_t * buf, size_t buflen)
return (fail(H));
}
if ((H->res.status < 100) || (H->res.status > 599)) {
warn0("Invalid HTTP status code: %i", H->res.status);
warn0("Invalid HTTP status code: %d", H->res.status);
return (fail(H));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/crc32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_crc32 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/crc32/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_crc32 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
2 changes: 1 addition & 1 deletion tests/crypto_aes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_crypto_aes -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/crypto_aes/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_crypto_aes -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
2 changes: 1 addition & 1 deletion tests/crypto_aesctr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_crypto_aesctr -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/crypto_aesctr/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_crypto_aesctr -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
6 changes: 3 additions & 3 deletions tests/elasticarray/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test_intlist(void)
/* Use the list. */
for (i = 0; i < intlist_getsize(list); i++) {
x = *intlist_get(list, i);
printf("int:\t%i\n", x);
printf("int:\t%d\n", x);
}

/* Free memory. */
Expand Down Expand Up @@ -90,7 +90,7 @@ test_dynlist(void)
/* Use the list. */
for (i = 0; i < dynlist_getsize(list); i++) {
d = *dynlist_get(list, i);
printf("dyn:\t%i\n", d.arr[0]);
printf("dyn:\t%d\n", d.arr[0]);
}

/* Free memory. */
Expand Down Expand Up @@ -148,7 +148,7 @@ test_pointerlist(void)
/* Use the list. */
for (i = 0; i < pointerlist_getsize(list); i++) {
p = *pointerlist_get(list, i);
printf("pointer:\t%i\n", p->arr[0]);
printf("pointer:\t%d\n", p->arr[0]);
}

/* Free memory. */
Expand Down
2 changes: 1 addition & 1 deletion tests/events/events_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ events_counter_ping(void)
{

/* Print the current count. */
printf("event %i\n", events_counter);
printf("event %d\n", events_counter);

/* Increment. */
events_counter++;
Expand Down
4 changes: 2 additions & 2 deletions tests/fork_func/check_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sleep_print_func(void * cookie)
millisleep((size_t)ms);

/* Write the "waited" messages to stderr. */
if (fprintf(stderr, "waited %i ms\n", ms) < 0) {
if (fprintf(stderr, "waited %d ms\n", ms) < 0) {
warnp("fprintf");
goto err0;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ check_order(void)

/* Write the "spawning" messages to stdout. */
for (i = 0; i < NUM_PROCESSES; i++) {
if (fprintf(stdout, "spawning a process to wait %i ms\n",
if (fprintf(stdout, "spawning a process to wait %d ms\n",
SLEEP_SORT_MS[i]) < 0) {
warnp("fprintf");
goto err0;
Expand Down
2 changes: 1 addition & 1 deletion tests/fork_func/check_perftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static inline void
print_timediff(int type, struct timeval tv_orig, struct timeval tv_now, int ms)
{

printf("%i\t%.4f\n", type,
printf("%d\t%.4f\n", type,
1000.0 * timeval_diff(tv_orig, tv_now) - (double)ms);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/md5/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_md5 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/md5/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_md5 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
4 changes: 2 additions & 2 deletions tests/monoclock/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ main(int argc, char * argv[])
}

/* Display times. */
printf("monoclock_get():\t\t%ju seconds,\t%06ji microseconds\n",
printf("monoclock_get():\t\t%ju seconds,\t%06jd microseconds\n",
(uintmax_t)tv_wall.tv_sec, (intmax_t)tv_wall.tv_usec);
printf("monoclock_get_cputime():\t%ju seconds,\t%06ji microseconds\n",
printf("monoclock_get_cputime():\t%ju seconds,\t%06jd microseconds\n",
(uintmax_t)tv_cpu.tv_sec, (intmax_t)tv_cpu.tv_usec);
printf("monoclock_getres():\t\t%g\n", timer_resolution);

Expand Down
2 changes: 1 addition & 1 deletion tests/mpool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ main(int argc, char * argv[])
/* Time memory allocation method, and output it. */
if ((delta_us = time_func(sets, reps, use_mpool)) < 0)
goto err0;
printf("%lli\n", delta_us);
printf("%lld\n", delta_us);

/* Success! */
exit(0);
Expand Down
8 changes: 4 additions & 4 deletions tests/parsenum/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ parsenum_equal(double x, double y)
#define TEST_EX6_DO(str, var, min, max, target, base, trailing) \
var parsenum_x; \
int parsenum_ret; \
printf("Parsing \"%s\" in base %i as %s with trailing" \
" %i between %s and %s (incl.) yields " target \
printf("Parsing \"%s\" in base %d as %s with trailing" \
" %d between %s and %s (incl.) yields " target \
"... ", str, base, #var, trailing, #min, #max); \
parsenum_ret = PARSENUM_EX(&parsenum_x, str, min, max, base, trailing);

#define TEST_EX4_DO(str, var, target, base, trailing) \
var parsenum_x; \
int parsenum_ret; \
printf("Parsing \"%s\" in base %i as %s with trailing" \
" %i yields " target "... ", str, base, #var, \
printf("Parsing \"%s\" in base %d as %s with trailing" \
" %d yields " target "... ", str, base, #var, \
trailing); \
parsenum_ret = PARSENUM_EX(&parsenum_x, str, base, trailing);

Expand Down
2 changes: 1 addition & 1 deletion tests/sha1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_sha1 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/sha1/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_sha1 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
2 changes: 1 addition & 1 deletion tests/sha256/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_sha256 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/sha256/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_sha256 -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
2 changes: 1 addition & 1 deletion tests/shared_test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ wait_while() {
while "$@"; do
# Notify user (if desired)
if [ "${VERBOSE}" -ne 0 ]; then
printf "waited\t%ims\t%s\n" \
printf "waited\t%dms\t%s\n" \
"${_wait_while_ms}" "$*" 1>&2
fi

Expand Down
2 changes: 1 addition & 1 deletion tests/shared_valgrind_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ _val_generalize() {
_val_generalize_i=1
while [ "${_val_generalize_i}" -le "${_val_generalize_num_segments}" ]; do
# Process segment
_val_seg "$(printf "%s%02i" \
_val_seg "$(printf "%s%02d" \
"${_val_generalize_filename}" "${_val_generalize_i}")"

# Advance to the next suppression.
Expand Down
2 changes: 1 addition & 1 deletion tests/sysendian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_sysendian -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
2 changes: 1 addition & 1 deletion tests/sysendian/Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ perftest:
@printf "# nblks\tbsize\ttime\tspeed\n"
@./test_sysendian -t | \
grep "blocks" | \
awk '{ printf "%i\t%i\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'
awk '{ printf "%d\t%d\t%.6f\t%.6f\n", $$1, $$5, $$6, $$8}'

.include <bsd.prog.mk>
6 changes: 3 additions & 3 deletions tests/warnp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ print_stuff(const char * extra_message)

/* Output messages involving warnp with a formatted message. */
errno = 0;
warnp("warnp errno %i", 0);
warnp("warnp errno %d", 0);

errno = 2;
warnp("warnp errno %i", 2);
warnp("warnp errno %d", 2);

/* Output long message. */
print_long_message();
Expand Down Expand Up @@ -81,7 +81,7 @@ workthread(void * cookie)
/* Output a bunch of messages. */
for (i = 0; i < 10; i++) {
errno = ENOENT;
warnp("thread #%i val %i", num, i);
warnp("thread #%d val %d", num, i);
}

/* Success! */
Expand Down

0 comments on commit 917ccb2

Please sign in to comment.