Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts/checkpatch: Check for patches adding #defines for libc APIs #60487

Merged

Conversation

keith-packard
Copy link
Collaborator

All code in the Zephyr core must use only the Zephyr C library API according to rules A.4 and A.5. Such code is not permitted to request API extensions from the C library via any of the API request mechanisms.

This addition to checkpatch.pl verifies that patches don't #define any of these:

__STRICT_ANSI__
_POSIX_SOURCE
_POSIX_C_SOURCE
_XOPEN_SOURCE
_ISOC99_SOURCE
_ISOC11_SOURCE
_ATFILE_SOURCE
_GNU_SOURCE
_BSD_SOURCE
_SVID_SOURCE
_DEFAULT_SOURCE

Reference: #49922

Comment on lines 596 to 598
_POSIX_SOURCE|
_POSIX_C_SOURCE|
_XOPEN_SOURCE|
_XOPEN_SOURCE_EXTENDED|
_ISOC99_SOURCE|
_ISOC11_SOURCE|
_ATFILE_SOURCE|
_GNU_SOURCE|
_BSD_SOURCE|
_SVID_SOURCE|
_DEFAULT_SOURCE
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking - prefer you alphabetize these.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call. done.

@@ -6527,6 +6541,13 @@ sub process {
}
}

# check for #defines of various API specifying things like _POSIX_C_SOURCE
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# check for #defines of various API specifying things like _POSIX_C_SOURCE
# check for feature test macros that request C library API extensions, violating rules A.4 and A.5

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

always best to say 'why' and not 'what' in your commit messages. thanks for the fix.

All code in the Zephyr core must use only the Zephyr C library API
according to rules A.4 and A.5. Such code is not permitted to request API
extensions from the C library via any of the API request mechanisms.

This addition to checkpatch.pl verifies that patches don't #define
any of these:

	__STRICT_ANSI__
	_POSIX_SOURCE
	_POSIX_C_SOURCE
	_XOPEN_SOURCE
	_ISOC99_SOURCE
	_ISOC11_SOURCE
	_ATFILE_SOURCE
	_GNU_SOURCE
	_BSD_SOURCE
	_SVID_SOURCE
	_DEFAULT_SOURCE

Reference: zephyrproject-rtos#49922

Signed-off-by: Keith Packard <keithp@keithp.com>
@fabiobaltieri fabiobaltieri merged commit b021dec into zephyrproject-rtos:main Jul 18, 2023
12 checks passed
our $api_defines = qr{(?x:
_ATFILE_SOURCE|
_BSD_SOURCE|
_DEFAULT_SOURCE
Copy link
Collaborator

Choose a reason for hiding this comment

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

@keith-packard missing pipe might be the culprit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It actually got moved to the end of the pattern when I sorted the symbols upon request from a reviewer... Checkout #60551 for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Coding Guidelines Coding guidelines and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants