From d8b411fe1597988733a6768450ddb41b800244e5 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 20 May 2022 08:40:59 -0400 Subject: [PATCH] tests.c - Fix 'format-security' warnings due to use of ck_assert_msg() without a formatting string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://fedoraproject.org/wiki/Format-Security-FAQ#What_is_-Wformat-security tests.c: In function ‘test_minmea_check_fn’: tests.c:79:9: error: format not a string literal and no format arguments [-Werror=format-security] 79 | ck_assert_msg(minmea_check(*sentence, false) == true, *sentence); | ^~~~~~~~~~~~~ tests.c:80:9: error: format not a string literal and no format arguments [-Werror=format-security] 80 | ck_assert_msg(minmea_check(*sentence, true) == false, *sentence); | ^~~~~~~~~~~~~ tests.c:84:9: error: format not a string literal and no format arguments [-Werror=format-security] 84 | ck_assert_msg(minmea_check(*sentence, false) == true, *sentence); | ^~~~~~~~~~~~~ tests.c:85:9: error: format not a string literal and no format arguments [-Werror=format-security] 85 | ck_assert_msg(minmea_check(*sentence, true) == true, *sentence); | ^~~~~~~~~~~~~ tests.c:89:9: error: format not a string literal and no format arguments [-Werror=format-security] 89 | ck_assert_msg(minmea_check(*sentence, false) == false, *sentence); | ^~~~~~~~~~~~~ tests.c:90:9: error: format not a string literal and no format arguments [-Werror=format-security] 90 | ck_assert_msg(minmea_check(*sentence, true) == false, *sentence); | ^~~~~~~~~~~~~ --- tests.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests.c b/tests.c index c2ae730..7a31934 100644 --- a/tests.c +++ b/tests.c @@ -76,18 +76,18 @@ END_TEST START_TEST(test_minmea_check) { for (const char **sentence=valid_sentences_nochecksum; *sentence; sentence++) { - ck_assert_msg(minmea_check(*sentence, false) == true, *sentence); - ck_assert_msg(minmea_check(*sentence, true) == false, *sentence); + ck_assert_msg(minmea_check(*sentence, false) == true, "%s", *sentence); + ck_assert_msg(minmea_check(*sentence, true) == false, "%s", *sentence); } for (const char **sentence=valid_sentences_checksum; *sentence; sentence++) { - ck_assert_msg(minmea_check(*sentence, false) == true, *sentence); - ck_assert_msg(minmea_check(*sentence, true) == true, *sentence); + ck_assert_msg(minmea_check(*sentence, false) == true, "%s", *sentence); + ck_assert_msg(minmea_check(*sentence, true) == true, "%s", *sentence); } for (const char **sentence=invalid_sentences; *sentence; sentence++) { - ck_assert_msg(minmea_check(*sentence, false) == false, *sentence); - ck_assert_msg(minmea_check(*sentence, true) == false, *sentence); + ck_assert_msg(minmea_check(*sentence, false) == false, "%s", *sentence); + ck_assert_msg(minmea_check(*sentence, true) == false, "%s", *sentence); } } END_TEST