Skip to content

scripts/build: improve whitespace / empty parameter handling in syscall scripts #87633

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lonkaars
Copy link
Contributor

Syscall regex matches may include whitespace characters other than space (i.e. \n or \t), which causes gen_syscalls.py to fail. This mainly affects long system call signatures wrapped onto multiple lines (e.g. by code formatter). This change replaces all successive whitespace in the regex match groups with a single space.

Copy link

Hello @lonkaars, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@tejlmand
Copy link
Contributor

@lonkaars thanks for this.
Before approving then I would like to know if you have some examples where current parse_syscalls.py fails ?
Preferable in Zephyr repo, but external pointer is also ok.

This can help to see of we can make a test-case / update existing test case to ensure the problem is indeed fixed as well as ensureing there are no side-effects.

@lonkaars
Copy link
Contributor Author

I'm currently working in a private repository so I can't share the original code that this fix is for. I've created a twister test case in my (local) Zephyr fork clone with the following function signature, which fails in the same way:

__syscall void
test(int foo);

Should I add // clang-format off/on around the signature or does clang-format not touch tests? The repository I initially encountered this issue on uses AlignAfterOpenBracket: BlockIndent which is different from Zephyr's clang-format configuration.


While making the test case I also found gen_syscalls.py fails when a syscall is declared without parameters. Should I fix and append it to this PR or open a separate one?

@tejlmand
Copy link
Contributor

I'm currently working in a private repository so I can't share the original code that this fix is for.

I was assuming so.

I've created a twister test case in my (local) Zephyr fork clone with the following function signature, which fails in the same way:

__syscall void
test(int foo);

would be nice to have as part of this PR.
Most tooling is indirectly tested as it's used by Zephyr itself, but when having parts that are not indirectly tested in-tree, such as this line-wrap support, then having test-case to unsure functionality is always good.

While making the test case I also found gen_syscalls.py fails when a syscall is declared without parameters. Should I fix and append it to this PR or open a separate one?

Making it part of this PR is fine.

@github-actions github-actions bot added the area: Userspace Userspace label Mar 28, 2025
@github-actions github-actions bot requested review from ceolin and dcpleung March 28, 2025 11:51
@lonkaars
Copy link
Contributor Author

Looking over the commit history on scripts/build/gen_syscalls.py I believe 1993ea0 can also be reverted as the \s+ match will cause both newlines and tab characters to be replaced in the json file generated by parse_syscalls.py.

@lonkaars lonkaars changed the title scripts/build: flatten whitespace in parse_syscalls.py scripts/build: improve whitespace / empty parameter handling in syscall scripts Mar 28, 2025
tejlmand
tejlmand previously approved these changes Mar 28, 2025
Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

Thanks for the work

@57300 57300 removed their request for review April 1, 2025 19:05
lonkaars added 4 commits May 24, 2025 09:40
Syscall regex matches may include whitespace characters other than space
(i.e. `\n` or `\t`), which causes `gen_syscalls.py` to fail. This mainly
affects long system call signatures wrapped onto multiple lines (e.g. by
code formatter). This change replaces all successive whitespace in the
regex match groups with a single space.

Signed-off-by: Loek Le Blansch <loek.le-blansch.pv@renesas.com>
Syscalls can be declared without taking any parameters, but
`gen_syscalls.py` crashes if a function that does not take parameters is
declared using empty parenthesis instead of a single `void` parameter. This
change allows the empty parenthesis notation for syscalls without
parameters.

Signed-off-by: Loek Le Blansch <loek.le-blansch.pv@renesas.com>
This commit adds tests for whitespace in syscall declaration function
signatures and signatures without parameters.

Signed-off-by: Loek Le Blansch <loek.le-blansch.pv@renesas.com>
This reverts commit 1993ea0 because the
`parse_syscalls.py` script has been modified to not output whitespace
characters other than spaces in the generated JSON file.

Signed-off-by: Loek Le Blansch <loek.le-blansch.pv@renesas.com>
Copy link

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