From ed605d489c97cb154cf5eeda1d0634179dbffa8a Mon Sep 17 00:00:00 2001 From: Melkor-1 <140725427+Melkor-1@users.noreply.github.com> Date: Mon, 3 Jun 2024 05:44:46 +0000 Subject: [PATCH] fix: cast int to size_t to quieten compilers. In line 1831, a cast is required because `malloc()` expects a `size_t` as the first argument and an `int` was provided. The cast is perfectly safe here, as the number of tests can not be signed. Perhaps the better choice would have been to declare `acutest_list_size_` as an `unsigned` type. GCC-13.1 with -Wconversion complains about this. --- include/acutest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/acutest.h b/include/acutest.h index 5f9cb19..5583832 100644 --- a/include/acutest.h +++ b/include/acutest.h @@ -1828,7 +1828,7 @@ main(int argc, char** argv) for(i = 0; acutest_list_[i].func != NULL; i++) acutest_list_size_++; - acutest_test_data_ = (struct acutest_test_data_*)calloc(acutest_list_size_, sizeof(struct acutest_test_data_)); + acutest_test_data_ = (struct acutest_test_data_*)calloc((size_t) acutest_list_size_, sizeof(struct acutest_test_data_)); if(acutest_test_data_ == NULL) { fprintf(stderr, "Out of memory.\n"); acutest_exit_(2);