tests.c - Fix 'format-security' warnings due to use of ck_assert_msg() without a formatting string

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);
      |         ^~~~~~~~~~~~~
This commit is contained in:
Chris Morgan 2022-05-20 08:40:59 -04:00
parent 06ad5a1840
commit d8b411fe15

12
tests.c
View File

@ -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