Skip to content

dist/tools: add double #pragma once error message to headerguards check#21696

Merged
crasbe merged 1 commit intoRIOT-OS:masterfrom
crasbe:pr/double_pragma
Sep 5, 2025
Merged

dist/tools: add double #pragma once error message to headerguards check#21696
crasbe merged 1 commit intoRIOT-OS:masterfrom
crasbe:pr/double_pragma

Conversation

@crasbe
Copy link
Copy Markdown
Contributor

@crasbe crasbe commented Sep 5, 2025

Contribution description

Currently the headerguards check will only output broken header guard if more than one #pragma once is present in the file. This PR adds a separate case to print a dedicated error mesage for that case.

Testing procedure

Add a second #pragma once to your favorite header and observe the output:

master:

buechse@skyleaf:~/RIOTstuff/riot-vanilla/RIOT$ ./dist/tools/headerguards/check.sh
boards/adafruit-feather-nrf52840-sense/include/bat_voltage_params.h: broken header guard

This PR:

buechse@skyleaf:~/RIOTstuff/riot-vanilla/RIOT$ ./dist/tools/headerguards/check.sh
boards/adafruit-feather-nrf52840-sense/include/bat_voltage_params.h: More than one #pragma once in the same file

Issues/PRs references

Found in #21022.

@crasbe crasbe requested a review from miri64 September 5, 2025 08:33
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs labels Sep 5, 2025
@github-actions github-actions bot added the Area: tools Area: Supplementary tools label Sep 5, 2025
@crasbe crasbe changed the title dist/tools: add double #pragma once error message dist/tools: add double #pragma once error message to headerguards check Sep 5, 2025
@crasbe crasbe requested a review from benpicco September 5, 2025 09:46
@riot-ci
Copy link
Copy Markdown

riot-ci commented Sep 5, 2025

Murdock results

✔️ PASSED

22ade24 dist/tools: add double pragma error message to headerguard check

Success Failures Total Runtime
1 0 1 01m:58s

Artifacts

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

ACK.

(apart from my comment, the code could benefit from some decluttering with black as well, but that is for another PR)

Comment on lines +102 to +103
print("%s: More than one #pragma once in the same file" %
filename, file=sys.stderr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does not have to be for this PR, but

Suggested change
print("%s: More than one #pragma once in the same file" %
filename, file=sys.stderr)
print(f"{filename}: More than one #pragma once in the same file",
file=sys.stderr)

in almost any case is more performant (and I don't think we do still run python versions that do not support f-strings).

@crasbe crasbe added this pull request to the merge queue Sep 5, 2025
Merged via the queue into RIOT-OS:master with commit 44744e5 Sep 5, 2025
26 checks passed
@crasbe crasbe deleted the pr/double_pragma branch September 5, 2025 18:42
@benpicco benpicco added this to the Release 2025.10 milestone Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants