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

GUIDINGLI 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 efd476fa894 libs/libc: make printf octal formatting optional for 
DEFAULT_SMALL
efd476fa894 is described below

commit efd476fa894de54c4dca993145cd7ae6508ba6f1
Author: Swatantra Yadav <[email protected]>
AuthorDate: Sun Nov 22 19:59:05 2026 +0530

    libs/libc: make printf octal formatting optional for DEFAULT_SMALL
    
    Memory-constrained embedded targets (DEFAULT_SMALL=y) rarely format
    integers in octal notation (%o). The vsprintf engine in
    libs/libc/stream/lib_libvsprintf.c already provides dead-code elimination
    via CONFIG_LIBC_PRINTF_OCTAL, printing '?' when octal support is disabled.
    However, CONFIG_LIBC_PRINTF_OCTAL currently defaults unconditionally to 'y'.
    
    Change CONFIG_LIBC_PRINTF_OCTAL to default to LIBC_PRINTF_FULL ||
    !DEFAULT_SMALL. This eliminates octal parsing, alternate form (%#o)
    checks, and base-8 conversion logic on small profiles, saving 178 bytes
    of Flash (text) and 32 bytes of bss in lib_libvsprintf.o (176 bytes of
    Flash in the linked nuttx binary on sim:nsh), while preserving full
    conformance when LIBC_PRINTF_FULL is selected or on standard targets.
    
    Assisted-by: Claude:claude-opus-4.6
    Signed-off-by: Swatantra Yadav <[email protected]>
---
 Documentation/os/libs/libc/printf.rst | 3 ++-
 libs/libc/stdio/Kconfig               | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/os/libs/libc/printf.rst 
b/Documentation/os/libs/libc/printf.rst
index 5b4f9e2b5e7..14713f91e3f 100644
--- a/Documentation/os/libs/libc/printf.rst
+++ b/Documentation/os/libs/libc/printf.rst
@@ -309,7 +309,8 @@ Option                         Minimal     Default      Full
 =============================  ==========  ===========  ======
 
 In Default, ``LIBC_FLOATINGPOINT`` is on when ``DEFAULT_SMALL`` is off and the
-CPU has an FPU, as before the profiles existed.  In Minimal,
+CPU has an FPU, as before the profiles existed.  ``LIBC_PRINTF_OCTAL`` is on
+unless ``DEFAULT_SMALL`` is enabled.  In Minimal,
 ``LIBC_PRINTF_LONG_LONG`` stays on with ``SYSLOG_TIMESTAMP`` or ``FS_PROCFS``,
 because the log time stamps and ``/proc`` print ``time_t`` and ``uint64_t``.
 
diff --git a/libs/libc/stdio/Kconfig b/libs/libc/stdio/Kconfig
index bdcf7c54610..d8419f88ac0 100644
--- a/libs/libc/stdio/Kconfig
+++ b/libs/libc/stdio/Kconfig
@@ -125,7 +125,7 @@ config LIBC_PRINTF_ALT_FORM
 
 config LIBC_PRINTF_OCTAL
        bool "Enable %o in printf"
-       default y
+       default LIBC_PRINTF_FULL || !DEFAULT_SMALL
        ---help---
                Without it, printf() reads the argument of %o and prints "?".
 

Reply via email to