Repository navigation
apps: Include the headers that are used. - #3839
Merged
Merged
Conversation
casaroli
force-pushed
the
apps-include-headers
branch
from
October 12, 2026 12:25
6aa3ebc to
5080d13
Compare
xiaoxiang781216
previously approved these changes
Oct 12, 2026
casaroli
force-pushed
the
apps-include-headers
branch
from
October 13, 2026 04:25
5080d13 to
c6ea72b
Compare
The next commit adds includes to these files, and checkpatch checks each
changed file as a whole. So fix their old nxstyle errors first: the
indentation of case labels and other lines, blank lines after
declarations, a long comment, and a long string (split in two, with the
same output). Only the layout changes.
codespell also checks the whole files: fix "Types" and "transfer" in
sb_main.c, "corresponds" in hx711_main.c and "primitive" in
i8sak_acceptassoc.c, and add the path line of testing/drivers/ser/ser.c
to .codespell-ignore-lines ("ser" is not a typo there).
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
apps-include-headers
branch
from
October 13, 2026 05:25
c6ea72b to
6910dc5
Compare
These files use declarations from stdlib.h, unistd.h, pthread.h and other headers without including them. They got the declarations only because stdio.h included nuttx/lib/lib.h, and through it stdlib.h, nuttx/sched.h and more. - stdlib.h: adjtime, ads7046, audio_rttl, baromonitor, bmp280, hx711, netpkt_ethercat, nimble_blecent (main, peer), nimble_bleprph (main, gatt_svr), shv-test, stepper, tmp112, dhcpd, netlib_iptables, netlib_ip6tables, adcscope, iptables, ip6tables, nxdiag, sensorscope, nxboot boot.c, nand_sim, pcitest, cachetest, ymodem rb and sb. - unistd.h: nxboot boot.c and flash.c, fbcon, netpkt_ethercat, nimble_blecent, nimble_bleprph, shv-test, stepper, watched, lapi_other, ofloader, nand_sim, ser, setest, drivertest_block, drivertest_i2c_spi, drivertest_relay, epoll, fdsantest_simple, memfd_test, i8sak_acceptassoc, passwd_delete, plcatool. NXDoom: in i_timer.h, which every file that calls usleep() includes. - pthread.h: camera_bkgd, mqttc_pub, nxterm, pty_test, pwfb_events, pwlines_events, ofloader, epoll, memfd_test, ostest sched_thread_local.c and i8sak.h. - sched.h: ble_main, calib_udelay, drivertest_pm_smp. nuttx/atomic.h: the atomic test. nuttx/kmalloc.h: nand_sim, drivertest_block. - testing/cmocka: the downloaded cmocka.c uses ftruncate(); include unistd.h in cmocka_platform.h, which cmocka.c includes. - system/zlib: the downloaded gzlib.c, gzread.c and gzwrite.c use lseek(), read() and write(); make zconf.h include unistd.h, as zlib's configure does on Unix. - interpreters/wamr: the NuttX platform of older WAMR versions (sim:wamr pins one) uses the pthread types without including pthread.h; build WAMR with -include pthread.h. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
apps-include-headers
branch
from
October 13, 2026 06:34
6910dc5 to
20fb2df
Compare
cederom
approved these changes
Oct 13, 2026
xiaoxiang781216
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Some apps files use declarations from
stdlib.h,unistd.h,pthread.hand other headers without including them. They got the declarations only because NuttX'sstdio.hincludednuttx/lib/lib.h, and through itstdlib.h,nuttx/sched.hand more. apache/nuttx#20565 stops this.stdlib.h: adjtime, ads7046, audio_rttl, baromonitor, bmp280, hx711, netpkt_ethercat, nimble_blecent (main, peer), nimble_bleprph (main, gatt_svr), shv-test, stepper, tmp112, dhcpd, netlib_iptables, netlib_ip6tables, adcscope, iptables, ip6tables, nxdiag, sensorscope, nxbootboot.c, nand_sim, pcitest, cachetest, ymodemrb_main.candsb_main.c.unistd.h: nxbootboot.candflash.c, fbcon, netpkt_ethercat, nimble_blecent, nimble_bleprph, shv-test, stepper, watched, lapi_other, ofloader, nand_sim, ser, setest, drivertest_block, drivertest_i2c_spi, drivertest_relay, epoll, fdsantest_simple, memfd_test, i8sak_acceptassoc, passwd_delete, plcatool. NXDoom: ini_timer.h, which every NXDoom file that callsusleep()includes.pthread.h: camera_bkgd, mqttc_pub, nxterm, pty_test, pwfb_events, pwlines_events, ofloader, epoll, memfd_test, ostestsched_thread_local.c,i8sak.h.sched.h: ble_main, calib_udelay, drivertest_pm_smp.nuttx/atomic.h: the atomic test.nuttx/kmalloc.h: nand_sim, drivertest_block.testing/cmocka: the downloadedcmocka.cusesftruncate().cmocka_platform.h, whichcmocka.cincludes, now includesunistd.h.system/zlib: the downloadedgzlib.c,gzread.candgzwrite.cuselseek(),read()andwrite(). After the download, the Make and CMake builds now makezconf.hincludeunistd.h, as zlib'sconfiguredoes on Unix (#ifdef HAVE_UNISTD_Hbecomes#if 1), so zlib and the programs that includezlib.hagree onz_off_t.The first commit fixes the old nxstyle and codespell errors in the changed files, because CI checks each changed file as a whole. Only the layout changes, plus four spelling fixes and one
.codespell-ignore-linesentry (the pathtesting/drivers/ser/ser.c).Impact
None on master. Needed by apache/nuttx#20565.
Testing
To find every file, each of the 1753 apps C files was compiled with
-fsyntax-only -Werror=implicit-function-declaration, once against nuttx master and once against apache/nuttx#20565, forqemu-armv8a:nsh,qemu-armv8a:knsh,sim:citestandsim:ostest. The errors that only #20565 gives are all fixed. Files that include headers of downloaded packages (lvgl, nimble, cmocka and others) were checked again with empty stand-ins for the missing headers and the real include directories of the apps tree. What remains is config dependent (for exampleapb_alloc()withoutCONFIG_AUDIO), and in a kernel build, programs that call kernel functions (register_driver(),open_blockdriver(),task_create()), which cannot run there anyway.Not changed:
examples/sensor_fusion/sensor_fusion_main.c(EXIT_SUCCESS) andcrypto/openssl_mbedtls_wrapper/mbedtls/bio_lib.c(free()) needstdlib.htoo, but nxstyle rejects their mixed-case library names (Fusion, OpenSSL), so CI would fail on any change to them. No configuration in the tree builds them.examples/nanoxtermis not changed either: its errors show only with the stand-ins for the Nano-X headers, which were not available for the check.Earlier checks, with apache/nuttx#20565, Make,
-Werror, on macOS:esp32c6-devkitc:oa_tc6,stm32f746g-disco:dropbearandlinum-stm32h753bi:zbusfailed before and build after.qemu-armv7a:full(withmake -k) compiles the zlib and ymodem files without errors; its remaining errors are in libcxx and mbedtls, as on master.qemu-armv8a:nshwithCONFIG_LIB_ZLIBbuilds with Make and with CMake.tools/checkpatch.sh -c -u -m -gpasses.