summaryrefslogtreecommitdiff
path: root/ports/unix/coverage.c
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-06-24 10:07:37 +0200
committerDamien George <damien@micropython.org>2025-07-25 10:57:39 +1000
commita1a8eacdce18b953bf16e669b1519b79ca3ab49d (patch)
treee8d84865488e05a7b751b23f7e467225e043d933 /ports/unix/coverage.c
parentd0d111356f36373bdda387626162f60b38f2177a (diff)
unix/coverage: Avoid type checking an invalid string.
We still want this not to crash a runtime but the new static checker wouldn't like it. Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'ports/unix/coverage.c')
-rw-r--r--ports/unix/coverage.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c
index 68340d7f2..5bd02f6fb 100644
--- a/ports/unix/coverage.c
+++ b/ports/unix/coverage.c
@@ -230,7 +230,12 @@ static mp_obj_t extra_coverage(void) {
mp_printf(&mp_plat_print, "%u\n", 0x80000000); // should print unsigned
mp_printf(&mp_plat_print, "%x\n", 0x8000000f); // should print unsigned
mp_printf(&mp_plat_print, "%X\n", 0x8000000f); // should print unsigned
- mp_printf(&mp_plat_print, "abc\n%"); // string ends in middle of format specifier
+ // note: storing the string in a variable is enough to prevent the
+ // format string checker from checking this format string. Otherwise,
+ // it would be a compile time diagnostic under the format string
+ // checker.
+ const char msg[] = "abc\n%";
+ mp_printf(&mp_plat_print, msg); // string ends in middle of format specifier
mp_printf(&mp_plat_print, "%%\n"); // literal % character
mp_printf(&mp_plat_print, ".%-3s.\n", "a"); // left adjust