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

base_parser: bugfix ifdef ifndef evaluation #698

Merged
merged 4 commits into from
Feb 20, 2025

Conversation

Javagedes
Copy link
Contributor

@Javagedes Javagedes commented Feb 20, 2025

Previously, ifdef / ifndef evaluation was done by replacing the macro with a "0" if it was not defined then when evaluating the conditional, it was just verified if the value was "0" or not. This left open a scenario where a macro is defined but defined as an empty string. In this scenario, the parser would successfully replace the macro value, but in replacing it with an empty string, if left bare conditionals (e.g. the line was only !ifdef or !ifndef, which would cause an exception when attempting to evaluate that conditional.

This commit updates the logic to only check if the macro is defined or not, replacing the value with a "0" if missing, or a "1" if existing. Now, regardless of the value of the macro, the conditional will always be valid.

fixed #697

@Javagedes Javagedes added the bug Something isn't working label Feb 20, 2025
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.45%. Comparing base (ce85203) to head (4b70e00).
Report is 133 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #698      +/-   ##
==========================================
+ Coverage   81.43%   81.45%   +0.02%     
==========================================
  Files          56       45      -11     
  Lines        7514     7496      -18     
==========================================
- Hits         6119     6106      -13     
+ Misses       1395     1390       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Javagedes Javagedes requested review from apop5 and makubacki February 20, 2025 21:26
@Javagedes Javagedes added this to the v0.22.6 milestone Feb 20, 2025
@Javagedes Javagedes merged commit 4660132 into tianocore:master Feb 20, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: base_parser: !ifdef / !ifndef crashes when value defined as ""
3 participants