This is an automated email from the ASF dual-hosted git repository.
acassis 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 43f7f34b995 include: Make the limits and the formats of int_fast16_t
fit the type.
43f7f34b995 is described below
commit 43f7f34b9958283b4403789c9bc21df920fd3143
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Nov 5 20:17:02 2026 +0100
include: Make the limits and the formats of int_fast16_t fit the type.
int_fast16_t and uint_fast16_t are int and unsigned int, but
INT_FAST16_MIN, INT_FAST16_MAX and UINT_FAST16_MAX have the 16-bit
values. Where int has 32 bits, INT_FAST16_MAX is smaller than the
largest value of the type.
SCNdFAST16 and the other scan formats are the 16-bit ones, so sscanf()
stores 2 bytes of a 4-byte object: an int_fast16_t of -1 that scans "5"
becomes -65531 on a little endian CPU.
Take the limits from INT_MIN, INT_MAX and UINT_MAX, and use the formats
of int. The type does not change.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
arch/ceva/include/inttypes.h | 10 +++++-----
include/inttypes.h | 22 +++++++++++-----------
include/stdint.h | 6 +++---
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/arch/ceva/include/inttypes.h b/arch/ceva/include/inttypes.h
index d542dd9b369..259a5745def 100644
--- a/arch/ceva/include/inttypes.h
+++ b/arch/ceva/include/inttypes.h
@@ -150,7 +150,7 @@
#define SCNdLEAST64 "lld"
#define SCNdFAST8 "hhd"
-#define SCNdFAST16 "hd"
+#define SCNdFAST16 "d"
#define SCNdFAST32 "d"
#define SCNdFAST64 "lld"
@@ -168,7 +168,7 @@
#define SCNiLEAST64 "lli"
#define SCNiFAST8 "hhi"
-#define SCNiFAST16 "hi"
+#define SCNiFAST16 "i"
#define SCNiFAST32 "i"
#define SCNiFAST64 "lli"
@@ -186,7 +186,7 @@
#define SCNoLEAST64 "llo"
#define SCNoFAST8 "hho"
-#define SCNoFAST16 "ho"
+#define SCNoFAST16 "o"
#define SCNoFAST32 "o"
#define SCNoFAST64 "llo"
@@ -204,7 +204,7 @@
#define SCNuLEAST64 "llu"
#define SCNuFAST8 "hhu"
-#define SCNuFAST16 "hu"
+#define SCNuFAST16 "u"
#define SCNuFAST32 "u"
#define SCNuFAST64 "llu"
@@ -222,7 +222,7 @@
#define SCNxLEAST64 "llx"
#define SCNxFAST8 "hhx"
-#define SCNxFAST16 "hx"
+#define SCNxFAST16 "x"
#define SCNxFAST32 "x"
#define SCNxFAST64 "llx"
diff --git a/include/inttypes.h b/include/inttypes.h
index 1735b60db84..89adb124b5c 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -147,7 +147,7 @@
#endif
#define PRIdFAST8 PRId8
-#define PRIdFAST16 PRId16
+#define PRIdFAST16 "d"
#define PRIdFAST32 PRId32
#if defined(PRId64)
#define PRIdFAST64 PRId64
@@ -161,7 +161,7 @@
#endif
#define PRIiFAST8 PRIi8
-#define PRIiFAST16 PRIi16
+#define PRIiFAST16 "i"
#define PRIiFAST32 PRIi32
#if defined(PRIi64)
#define PRIiFAST64 PRIi64
@@ -175,7 +175,7 @@
#endif
#define PRIoFAST8 PRIo8
-#define PRIoFAST16 PRIo16
+#define PRIoFAST16 "o"
#define PRIoFAST32 PRIo32
#if defined(PRIo64)
#define PRIoFAST64 PRIo64
@@ -189,7 +189,7 @@
#endif
#define PRIuFAST8 PRIu8
-#define PRIuFAST16 PRIu16
+#define PRIuFAST16 "u"
#define PRIuFAST32 PRIu32
#if defined(PRIu64)
#define PRIuFAST64 PRIu64
@@ -203,7 +203,7 @@
#endif
#define PRIxFAST8 PRIx8
-#define PRIxFAST16 PRIx16
+#define PRIxFAST16 "x"
#define PRIxFAST32 PRIx32
#if defined(PRIx64)
#define PRIxFAST64 PRIx64
@@ -217,7 +217,7 @@
#endif
#define PRIXFAST8 PRIX8
-#define PRIXFAST16 PRIX16
+#define PRIXFAST16 "X"
#define PRIXFAST32 PRIX32
#if defined(PRIX64)
#define PRIXFAST64 PRIX64
@@ -231,7 +231,7 @@
#endif
#define SCNdFAST8 SCNd8
-#define SCNdFAST16 SCNd16
+#define SCNdFAST16 "d"
#define SCNdFAST32 SCNd32
#if defined(SCNd64)
#define SCNdFAST64 SCNd64
@@ -245,7 +245,7 @@
#endif
#define SCNiFAST8 SCNi8
-#define SCNiFAST16 SCNi16
+#define SCNiFAST16 "i"
#define SCNiFAST32 SCNi32
#if defined(SCNi64)
#define SCNiFAST64 SCNi64
@@ -259,7 +259,7 @@
#endif
#define SCNoFAST8 SCNo8
-#define SCNoFAST16 SCNo16
+#define SCNoFAST16 "o"
#define SCNoFAST32 SCNo32
#if defined(SCNo64)
#define SCNoFAST64 SCNo64
@@ -273,7 +273,7 @@
#endif
#define SCNuFAST8 SCNu8
-#define SCNuFAST16 SCNu16
+#define SCNuFAST16 "u"
#define SCNuFAST32 SCNu32
#if defined(SCNu64)
#define SCNuFAST64 SCNu64
@@ -287,7 +287,7 @@
#endif
#define SCNxFAST8 SCNx8
-#define SCNxFAST16 SCNx16
+#define SCNxFAST16 "x"
#define SCNxFAST32 SCNx32
#if defined(SCNx64)
#define SCNxFAST64 SCNx64
diff --git a/include/stdint.h b/include/stdint.h
index 0feaf403da6..7598f44ac19 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -99,9 +99,9 @@
#define INT_FAST8_MAX INT8_MAX
#define UINT_FAST8_MAX UINT8_MAX
-#define INT_FAST16_MIN INT16_MIN
-#define INT_FAST16_MAX INT16_MAX
-#define UINT_FAST16_MAX UINT16_MAX
+#define INT_FAST16_MIN INT_MIN
+#define INT_FAST16_MAX INT_MAX
+#define UINT_FAST16_MAX UINT_MAX
#ifdef __INT24_DEFINED
# define INT_FAST24_MIN INT24_MIN