Skip to content

nshlib: Do not remove nsh_catfile() when cat is enabled - #4047

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
casaroli:nsh-catfile-up
Nov 14, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
casaroli:nsh-catfile-up

Conversation

@casaroli

@casaroli casaroli commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

nshlib/nsh.h undefines NSH_HAVE_CATFILE when cat, ifconfig, ifup/down, df, free and env are all enabled, and irqinfo and the mount list are not. The test of the six commands is inverted: cat always uses nsh_catfile(). With procfs, no network, no IRQ monitor and CONFIG_FS_PROCFS_EXCLUDE_MOUNT=y (qemu-armv8a:nsh), NSH does not build:

nsh_command.c:434:23: error: 'cmd_mount' undeclared here (not in a function); did you mean 'cmd_umount'?

More commands call nsh_catfile() than the list names (dmesg, fdinfo, route, ...). This PR removes the test, so nsh_catfile() is always built.

Impact

  • Configurations that hit the inverted test build again. In all other configurations NSH_HAVE_CATFILE was already defined, so they do not change.
  • A configuration with none of the commands keeps nsh_catfile() in nsh_fsutils.c; with --gc-sections the linker removes it.
  • No Kconfig or documentation change.

Testing

qemu-armv8a:nsh, EXTRAFLAGS="-Wno-cpp -Werror", aarch64-none-elf-gcc 14.2.1, nuttx master 562db43781f with apache/nuttx#21824 (the procfs fs/mount link fix): all 8 combinations of FS_PROCFS_EXCLUDE_MOUNT, _BLOCKS and _USAGE build with no warnings. In QEMU with FS_PROCFS_EXCLUDE_MOUNT=y, cat, df and df -h work. nuttx-apps master fails as shown above.

tools/checkpatch.sh -c -u -m -g passes.

nsh.h undefines NSH_HAVE_CATFILE when cat, ifconfig, ifup/down, df,
free and env are all enabled, and irqinfo and the mount list are not.
The test of the six commands is inverted: cat always uses
nsh_catfile().  With procfs, no network, no IRQ monitor and
CONFIG_FS_PROCFS_EXCLUDE_MOUNT=y, the build fails:

  nsh_command.c: error: 'cmd_mount' undeclared here

More commands use nsh_catfile() than the list names (dmesg, fdinfo,
route, ...).  Remove the test, so nsh_catfile() is always built.  With
--gc-sections, the linker removes it when no command uses it.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/43391400555

@xiaoxiang781216
xiaoxiang781216 merged commit 88d3c39 into apache:master Nov 14, 2026
60 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants