You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/11/15 11:45:40 UTC

(nuttx) branch master updated: the bug of sscanf exception output in arm64 platform

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new bb14e45ec9 the bug of sscanf exception output in arm64 platform
bb14e45ec9 is described below

commit bb14e45ec9bb4c93d2e9fdf6bdc8d8ca38441e86
Author: fengxuesong <fe...@xiaomi.com>
AuthorDate: Mon Nov 13 20:07:53 2023 +0800

    the bug of sscanf exception output in arm64 platform
    
    Signed-off-by: fengxuesong <fe...@xiaomi.com>
---
 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. */