Skip to content

drivers/serial: do not build serial drivers when CONFIG_SERIAL is disabled - #21047

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Swatantra-66:fs/uio-ops-guard
Nov 1, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
Swatantra-66:fs/uio-ops-guard

Conversation

@Swatantra-66

@Swatantra-66 Swatantra-66 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #20820 (fs/vfs: Add FS_UIO to option out vector I/O).

In #20820, CONFIG_FS_UIO was made a hidden option selected by CONFIG_SERIAL. However, in configurations where CONFIG_SERIAL is disabled (e.g. nucleo-f303re:can, stm32f4discovery:lwl, qemu-intel64:earlyfb), drivers/serial/Make.defs and drivers/serial/CMakeLists.txt were still unconditionally compiling serial.c and serial_io.c.

As pointed out by @xiaoxiang781216, serial.* should not be built when CONFIG_SERIAL is disabled.

This PR:

  1. Gates serial driver compilation in drivers/serial/Make.defs under ifeq ($(CONFIG_SERIAL),y).
  2. Gates serial driver compilation in drivers/serial/CMakeLists.txt under if(CONFIG_SERIAL).

(Note: We originally considered guarding readv/writev inside struct file_operations and struct mountpt_operations, but dropped it because positional initializers across multiple filesystems would shift callbacks when CONFIG_FS_UIO is disabled).

Impact

  • Is new feature added? No (build fix / footprint optimization).
  • User impact: None.
  • Build impact: Skips compiling serial.* when CONFIG_SERIAL is disabled, saving build time and flash.

Testing

  • ./tools/checkpatch.sh -c HEAD (0 errors, 0 warnings)
  • ./tools/configure.sh nucleo-f303re:can (verified configuration without serial builds cleanly)
  • ./tools/configure.sh sim:nsh (verified configuration with serial enabled)

@github-actions github-actions Bot added Area: File System File System issues Size: S The size of the change in this PR is small labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@Swatantra-66 please fix:

====================================================================================
Configuration/Tool: stm32ldiscovery/chrono,CONFIG_ARM_TOOLCHAIN_CLANG
2026-10-27 21:19:50
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_CLANG
  Building NuttX...
Error: serial/serial.c:180:3: error: excess elements in struct initializer [-Werror,-Wexcess-initializers]
  180 |   uart_readv,   /* readv */
      |   ^~~~~~~~~~

@Swatantra-66

Copy link
Copy Markdown
Contributor Author

Fixed. In configurations where CONFIG_SERIAL is disabled (such as stm32ldiscovery/chrono), CONFIG_FS_UIO is not defined while serial.c is still built. Guarded uart_readv, uart_writev, and related write helpers in drivers/serial/serial.c with CONFIG_FS_UIO

@jerpelea jerpelea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch looks like an AI Assisted one and I can not see the disclosure according the community guidelines

Please clarify!

@github-actions github-actions Bot added Area: Drivers Drivers issues and removed Area: File System File System issues labels Oct 28, 2026
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

@jerpelea AI assistance was used during the investigation. I have updated the commit message to include the Assisted-by Google Gemini disclosure tag in accordance with the Apache NuttX community guidelines

Comment thread drivers/serial/serial.c Resolved
@Swatantra-66 Swatantra-66 changed the title fs: Guard readv and writev operations with CONFIG_FS_UIO drivers/serial: do not build serial drivers when CONFIG_SERIAL is disabled Oct 28, 2026
@github-actions github-actions Bot added Size: XS The size of the change in this PR is very small and removed Size: S The size of the change in this PR is small labels Oct 28, 2026
@Swatantra-66

Swatantra-66 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Re-indented drivers/serial/CMakeLists.txt to pass cmake-format

@github-actions github-actions Bot added Size: M The size of the change in this PR is medium and removed Size: XS The size of the change in this PR is very small labels Oct 29, 2026
Comment thread drivers/serial/Make.defs Resolved
Comment thread drivers/serial/CMakeLists.txt Resolved
…abled

Previously, drivers/serial/Make.defs and CMakeLists.txt unconditionally
compiled serial.c and serial_io.c, even when CONFIG_SERIAL was disabled.
This caused unnecessary compilation and errors when CONFIG_SERIAL (which
selects CONFIG_FS_UIO) was disabled.

This change wraps serial driver compilation in drivers/serial/Make.defs
and drivers/serial/CMakeLists.txt under CONFIG_SERIAL.

Assisted-by: Google Gemini
Signed-off-by: Swatantra Yadav <[email protected]>
@github-actions github-actions Bot added Size: XS The size of the change in this PR is very small and removed Size: M The size of the change in this PR is medium labels Oct 30, 2026
@xiaoxiang781216
xiaoxiang781216 merged commit 5bb2a7a into apache:master Nov 1, 2026
132 of 177 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants