clar: use `size_t` to keep track of current line number We use the `__LINE__` macro in several places throughout clar to allow easier traceability when e.g. a test fails. While `__LINE__` is of type `size_t`, the clar functions all accept an integer and thus may loose precision. While unlikely that any file in our codebase will exceed a linecount of `INT_MAX`, let's convert it anyway to silence any compiler warnings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/tests/clar.c b/tests/clar.c
index 459ece0..7c308dd 100644
--- a/tests/clar.c
+++ b/tests/clar.c
@@ -96,7 +96,7 @@ fixture_path(const char *base, const char *fixture_name);
struct clar_error {
const char *file;
- int line_number;
+ size_t line_number;
const char *error_msg;
char *description;
@@ -589,7 +589,7 @@ void clar__skip(void)
void clar__fail(
const char *file,
- int line,
+ size_t line,
const char *error_msg,
const char *description,
int should_abort)
@@ -621,7 +621,7 @@ void clar__fail(
void clar__assert(
int condition,
const char *file,
- int line,
+ size_t line,
const char *error_msg,
const char *description,
int should_abort)
@@ -634,7 +634,7 @@ void clar__assert(
void clar__assert_equal(
const char *file,
- int line,
+ size_t line,
const char *err,
int should_abort,
const char *fmt,
diff --git a/tests/clar.h b/tests/clar.h
index 2f9f96b..20ff4c8 100644
--- a/tests/clar.h
+++ b/tests/clar.h
@@ -141,7 +141,7 @@ void clar__skip(void);
void clar__fail(
const char *file,
- int line,
+ size_t line,
const char *error,
const char *description,
int should_abort);
@@ -149,14 +149,14 @@ void clar__fail(
void clar__assert(
int condition,
const char *file,
- int line,
+ size_t line,
const char *error,
const char *description,
int should_abort);
void clar__assert_equal(
const char *file,
- int line,
+ size_t line,
const char *err,
int should_abort,
const char *fmt,
diff --git a/tests/clar/print.h b/tests/clar/print.h
index 73c4a89..2e2b620 100644
--- a/tests/clar/print.h
+++ b/tests/clar/print.h
@@ -20,7 +20,7 @@ static void clar_print_error(int num, const struct clar_report *report, const st
{
printf(" %d) Failure:\n", num);
- printf("%s::%s [%s:%d]\n",
+ printf("%s::%s [%s:%"PRIuZ"]\n",
report->suite,
report->test,
error->file,