-
Notifications
You must be signed in to change notification settings - Fork 30
Autogen: Extend macro typo checker for MLK_XXX/ MLKEM_XXX #816
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
base: main
Are you sure you want to change the base?
Conversation
willieyz
commented
Dec 26, 2025
- Related: Extend macro typo checker for wrongly ported MLK_XXX / MLKEM_XXX macros #785
- This PR extend the macro typo checker in autogen, for checking wrongly port MLK_XXX/ MLKEM_XXX
d3bd7f6 to
55d5412
Compare
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @willieyz. As I understand, with the change we would still allow MLK_FOO if there is #define MLK_FOO somewhere. That's not intended. We should not have any MLK_XXX or MLKEM_XXX macros in the mldsa-native code base.
55d5412 to
a8f9ccc
Compare
scripts/autogen
Outdated
| _RE_MARKDOWN_CITE = re.compile(r"\[\^(?P<id>\w+)\]") | ||
| _RE_C_CITE = re.compile(r"@\[(?P<id>\w+)") | ||
| _FORBIDDEN_PREFIXES = "MLK_|MLKEM_" | ||
| _RE_MACRO_CHECK = re.compile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_RE_MACRO_CHECK is overwritten again on line 37.
I suggest you keep it simple and just add a _RE_MLKEM_MACRO_CHECK which like, _RE_MACRO_CHECK, just with MLK/MLKEM, and then you add a separate check for their presence rather than extending the existing one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @hanno-becker , thank you for your review,
I had change the macro checking method according to your suggestion,
Now all checking logic related with MLK/MLKEM will be processing in separate part, and mange the macro in additional _RE_MLKEM_MACRO_CHECK, thank you for your help!
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
d6eb9f3 to
946bee7
Compare
| f"Likely typo {txt} in {filename}:{line_no}? Not a defined macro." | ||
| ) | ||
|
|
||
| # Separate check for wrongly ported MLK/MLKEM macros |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run this check first? Otherwise, if you wrongly port #define MLK_FOO ... but use MLD_FOO in the code, you'll get the error "Undefined macro MLD_FOO" from the first check, but it would be clearer to get the second error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @hanno-becker, thank you for your help.
You are correct. Thank you for pointing this issue out. I have adjusted the order based on your suggestion and verified it with selftests.
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
- This commit extend the macro tyop checker for catch wrongly port for MLK_XXX / MLKEM_XXX, by adding similar regex like _RE_MACRO_CHECK but with "MLK_|MLKEM_" and use it with a seperate check in check_macro_typos_in_file() - Also, for handle the cases in defines, like: #define MLK_FOO, this commit add a additional checking in check_macro_typos_in_file(), with above checking method. Signed-off-by: willieyz <[email protected]>
- This commit fixes a error cause by macro typo in .clang-format where MLK_INTERNAL_API
should be MLD_INTERNAL_API. This typo was detected after extending the
macro checker to catch wrongly ported MLK_XXX/MLKEM_XXX macros.
- The typo fix causes clang-format to reformat some files (packing.h and
polyvec.h) by changing macro order from:
MLD_MUST_CHECK_RETURN_VALUE
MLD_INTERNAL_API
to:
MLD_MUST_CHECK_RETURN_VALUE MLD_INTERNAL_API
- This reordering is the wrong, and it is because the order of these two macor,
after referece from mlkem-native, we switch the macro order from:
MLD_MUST_CHECK_RETURN_VALUE
MLD_INTERNAL_API
to:
MLD_INTERNAL_API
MLD_MUST_CHECK_RETURN_VALUE
This is correct formatting behavior and matches the mlkem-native convention.
Signed-off-by: willieyz <[email protected]>
- This commit fixes a error cause by macro typo in .clang-format
where MLK_UNION_OR_STRUCT should be
MLD_UNION_OR_STRUCT. This typo was detected after
extending the macro checker to catch wrongly ported
MLK_XXX/MLKEM_XXX macros.
Signed-off-by: willieyz <[email protected]>
946bee7 to
94bacce
Compare