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

checksrc.pl: BRACEPOS false positive #7863

Closed
MarcelRaad opened this issue Oct 15, 2021 · 1 comment
Closed

checksrc.pl: BRACEPOS false positive #7863

MarcelRaad opened this issue Oct 15, 2021 · 1 comment
Assignees
Labels

Comments

@MarcelRaad
Copy link
Member

@MarcelRaad MarcelRaad commented Oct 15, 2021

I did this

Run checksrc.pl on this code:
MarcelRaad@7de0894

I expected the following

Nothing to complain about. Instead, I got a BRACEPOS warning.

It excludes an opening brace if the line directly above it is a preprocessor directive starting with #. It should probably also exclude an opening brace if every line starting with the second one above ends with a \ until one starts with a #? I don't know how to nicely express that in perl though...

curl/libcurl version

N/A, checksrc.pl @ 2f0bb86

operating system

Ubuntu

@bagder bagder self-assigned this Oct 15, 2021
@bagder bagder added the script label Oct 15, 2021
@bagder
Copy link
Member

@bagder bagder commented Oct 16, 2021

It's a bit complicated.

I believe the right approach is to filter away preprocessor directives before the code is checked. But then we still need to allow certain "bending of the rules" when there are preprocessor instructions mixed with code...

I have a fix that I believe works at least for this case, but when working on this I also started to feel the need to add dedicated tests for checksrc so that we know that fixing a problem doesn't break old behavior or introduced new bugs... But I realize I need to put "checksrc tests" as a separate item/PR...

Loading

bagder added a commit that referenced this issue Oct 16, 2021
In order to check the actual code better, checksrc now ignores
everything that look like preprocessor instructions.

Note that some rules then still don't need to be followed when code is
exactly below a cpp instruction.

Reported-by: Marcel Raad
Fixes #7863
@bagder bagder closed this in 53418db Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants