Skip to content

Commit a1a8eac

Browse files
jeplerdpgeorge
authored andcommitted
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 <[email protected]>
1 parent d0d1113 commit a1a8eac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ports/unix/coverage.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,12 @@ static mp_obj_t extra_coverage(void) {
230230
mp_printf(&mp_plat_print, "%u\n", 0x80000000); // should print unsigned
231231
mp_printf(&mp_plat_print, "%x\n", 0x8000000f); // should print unsigned
232232
mp_printf(&mp_plat_print, "%X\n", 0x8000000f); // should print unsigned
233-
mp_printf(&mp_plat_print, "abc\n%"); // string ends in middle of format specifier
233+
// note: storing the string in a variable is enough to prevent the
234+
// format string checker from checking this format string. Otherwise,
235+
// it would be a compile time diagnostic under the format string
236+
// checker.
237+
const char msg[] = "abc\n%";
238+
mp_printf(&mp_plat_print, msg); // string ends in middle of format specifier
234239
mp_printf(&mp_plat_print, "%%\n"); // literal % character
235240
mp_printf(&mp_plat_print, ".%-3s.\n", "a"); // left adjust
236241

0 commit comments

Comments
 (0)