From bb14e45ec9bb4c93d2e9fdf6bdc8d8ca38441e86 Mon Sep 17 00:00:00 2001 From: fengxuesong Date: Mon, 13 Nov 2023 20:07:53 +0800 Subject: [PATCH] the bug of sscanf exception output in arm64 platform Signed-off-by: fengxuesong --- libs/libc/stdio/lib_libvscanf.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libs/libc/stdio/lib_libvscanf.c b/libs/libc/stdio/lib_libvscanf.c index ba60ae6361..53654632ec 100644 --- a/libs/libc/stdio/lib_libvscanf.c +++ b/libs/libc/stdio/lib_libvscanf.c @@ -315,6 +315,37 @@ int lib_vscanf(FAR struct lib_instream_s *stream, FAR int *lastc, fmt++; } } + else if (fmt_char(fmt) == 'z') + { + switch (sizeof(size_t)) + { + /* The only known cases that the default will be hit are + * (1) the eZ80 which has sizeof(size_t) = 3 which is the + * same as the sizeof(int). And (2) if + * CONFIG_HAVE_LONG_LONG + * is not enabled and sizeof(size_t) is equal to + * sizeof(unsigned long long). This latter case is an + * error. + */ + + default: + continue; /* Treat as integer with no size qualifier. */ + + case sizeof(unsigned short): + modifier = H_MOD; + break; + + case sizeof(unsigned long): + modifier = L_MOD; + break; + +#if defined(CONFIG_HAVE_LONG_LONG) && ULLONG_MAX != ULONG_MAX + case sizeof(unsigned long long): + modifier = LL_MOD; + break; +#endif + } + } else if (fmt_char(fmt) == 'j') { /* Same as long long if available. Otherwise, long. */