Skip to content

Commit 7d65d4c

Browse files
committed
tests: blame: fix conversion specifiers in format string
While the blame helper function `hunk_message` accepts a printf-style format string, we didn't add a compiler attribute to let the compiler check for correct conversion specifiers. As a result, some users of the function used wrong specifiers. Add the GIT_FORMAT_PRINTF attribute to the function and fix resulting warnings by using the correct specifiers.
1 parent bd6b1c4 commit 7d65d4c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tests/blame/blame_helpers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ void check_blame_hunk_index(git_repository *repo, git_blame *blame, int idx,
3131
}
3232

3333
if (hunk->final_start_line_number != start_line) {
34-
hunk_message(idx, hunk, "mismatched start line number: expected %d, got %d",
34+
hunk_message(idx, hunk, "mismatched start line number: expected %"PRIuZ", got %"PRIuZ,
3535
start_line, hunk->final_start_line_number);
3636
}
3737
cl_assert_equal_i(hunk->final_start_line_number, start_line);
3838

3939
if (hunk->lines_in_hunk != len) {
40-
hunk_message(idx, hunk, "mismatched line count: expected %d, got %d",
40+
hunk_message(idx, hunk, "mismatched line count: expected %"PRIuZ", got %"PRIuZ,
4141
len, hunk->lines_in_hunk);
4242
}
4343
cl_assert_equal_i(hunk->lines_in_hunk, len);

tests/blame/blame_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "clar_libgit2.h"
22
#include "blame.h"
33

4-
void hunk_message(size_t idx, const git_blame_hunk *hunk, const char *fmt, ...);
4+
void hunk_message(size_t idx, const git_blame_hunk *hunk, const char *fmt, ...) GIT_FORMAT_PRINTF(3, 4);
55

66
void check_blame_hunk_index(
77
git_repository *repo,

0 commit comments

Comments
 (0)