mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py/mpprint: Fail an assertion with unsupported format specifiers.
Arguments of an unknown type cannot be skipped and continuing to parse a format string after encountering an unknown format specifier leads to undefined behaviour. This patch helps to find use of unsupported formats.
This commit is contained in:
committed by
Damien George
parent
ce1c786297
commit
f98bb2ddcb
@@ -12,7 +12,6 @@ STATIC mp_obj_t extra_coverage(void) {
|
||||
// mp_printf (used by ports that don't have a native printf)
|
||||
{
|
||||
mp_printf(&mp_plat_print, "# mp_printf\n");
|
||||
mp_printf(&mp_plat_print, "%"); // nothing after percent
|
||||
mp_printf(&mp_plat_print, "%d %+d % d\n", -123, 123, 123); // sign
|
||||
mp_printf(&mp_plat_print, "%05d\n", -123); // negative number with zero padding
|
||||
mp_printf(&mp_plat_print, "%ld\n", 123); // long
|
||||
@@ -21,7 +20,6 @@ STATIC mp_obj_t extra_coverage(void) {
|
||||
mp_printf(&mp_plat_print, "%.*s\n", -1, "abc"); // negative string precision
|
||||
mp_printf(&mp_plat_print, "%b %b\n", 0, 1); // bools
|
||||
mp_printf(&mp_plat_print, "%s\n", NULL); // null string
|
||||
mp_printf(&mp_plat_print, "%t\n"); // non-format char
|
||||
mp_printf(&mp_plat_print, "%d\n", 0x80000000); // should print signed
|
||||
mp_printf(&mp_plat_print, "%u\n", 0x80000000); // should print unsigned
|
||||
mp_printf(&mp_plat_print, "%x\n", 0x80000000); // should print unsigned
|
||||
|
||||
Reference in New Issue
Block a user