Skip to content

Commit

Permalink
In printf, use %d instead of %i
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Jan 28, 2024
1 parent 697ebd6 commit 7532f47
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions STYLE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ not erroneous.)
The first statement in main(), after variable declarations, should be
"WARNP_INIT;" in order to set the program name used for printing warnings.

We use %d rather than %i in printf and warn0/warnp strings.

In general, functions should be structured with one return statement per
status, e.g., one return() for success and one return() for failure. Errors
should be handled by using goto to enter the error return path, e.g.,
Expand Down
4 changes: 2 additions & 2 deletions tar/siginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ siginfo_printinfo(struct bsdtar *bsdtar, off_t progress, int finalmsg)
if ((s_total_uncompressed = humansize(
siginfo->total_uncompressed)) == NULL)
goto err0;
safe_fprintf(stderr, "Processed %i entries, %s",
safe_fprintf(stderr, "Processed %d entries, %s",
siginfo->file_count, s_total_uncompressed);

/* Clean up. */
free(s_total_uncompressed);
} else {
safe_fprintf(stderr,
"Processed %i entries, %" PRId64 " bytes",
"Processed %d entries, %" PRId64 " bytes",
siginfo->file_count, siginfo->total_uncompressed);
}

Expand Down
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 tools/check_c_function_newline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def handle_file(filename):
if " " in func_text_search.split("(")[0]:
print("--------- WARNING: possible style violation")
print("\t%s" % filename)
print("\tline %i" % i)
print("\tline %d" % i)
print(func_text)
func_text = ""
if line[0] == "\t" or line[0] == " " or line[0] == "_":
Expand Down
2 changes: 1 addition & 1 deletion tools/check_includes_alphabetical.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def handle_file(filename):
if not is_block_correct_order(include_block):
print("Non-alphabetical include block")
print("\t%s" % filename)
print("\tstarts line %i" % i)
print("\tstarts line %d" % i)
print("\t%s" % include_block)
include_block = []

Expand Down

0 comments on commit 7532f47

Please sign in to comment.