Closed cfriedt closed 5 months ago
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
Describe the bug There are 2 main issues covered here with how
scripts/checkpatch.pl
enforces rules A.4 and A.5 of the coding guidelines.Rule A.4
Rule A.4 restricts the Zephyr kernel from being built with ISO C functions (and some POSIX functions) other than those listed.
However,
scripts/checkpatch.pl
looks at the entire Zephyr codebase when enforcing those restrictions rather than enforcing it for (only)kernel/
and (probably)include/zephyr/kernel*
.With that,
scripts/checkpatch.pl
currently generates false positives in CI for valid code changes that are not in violation of Rule A.4.Note: The rationale for Rule A.4 is to support building the Zephyr kernel with the minimal libc.
Rule A.5
Rule A.5 is there to restrict use of "C standard library functions and macros" in the Zephyr codebase to that of C11, mainly because e.g. Newlib and Picolibc also provide implementations of non-ISO-C library routines bundled with their versions of the C library.
However, Zephyr's POSIX API, network subsystem, as well as conformant applications and libraries do require being able to declare e.g.
_POSIX_C_SOURCE
or_XOPEN_SOURCE
(possibly gated via some Kconfig option) in order to signal to the implementation that POSIX prototypes and structures should be made available (See IEEE 1003.1-2017, section 2.2, "Application Conformance").We generally do want to support applications (libraries, etc) that are built according to standards.
Please also mention any information which could help others to understand the problem you're facing:
To Reproduce Steps to reproduce the behavior:
samples/hello_world
to usegethostname()
as in #67282Expected behavior Applications and libraries (outside of the kernel) should be able to depend on and select POSIX options and option groups without CI generating errors.
Impact A bit of a showstopper, since whenever reviewers see compliance failures, they assume that something is wrong with the code, but in many applications (particularly those in networking, fs, posix, etc), that is not the case.
Logs and console output
Environment (please complete the following information):
Additional context