Skip to content

Preprocessor: removed unreachable ConfigurationNotChecked finding#4790

Merged
danmar merged 1 commit intodanmar:mainfrom
firewave:notchk-2
Mar 2, 2023
Merged

Preprocessor: removed unreachable ConfigurationNotChecked finding#4790
danmar merged 1 commit intodanmar:mainfrom
firewave:notchk-2

Conversation

@firewave
Copy link
Collaborator

The finding can never be triggered Preprocessor::validateCfg() bails out when the define contains a = (e.g. DEF_1=1).

I came across this as I was trying to write a unit test for this and failed to trigger this.

cfg is generated by calling Preprocessor::createDUI(). That calls splitcfg(mSettings.userDefines, dui.defines, "1") to generate that config but as the last parameter shows it will set a default value of 1 if it is not specified. So it is not possible to generate a configuration which contains defines without any values and Preprocessor::validateCfg() will not be able to report any warnings.

I assume the configuration string was changed at some point rending that validation void.

@firewave
Copy link
Collaborator Author

The removed tests were feeding impossible data into the preprocessor. They use a custom preprocess() implementation which does not behave like the actual one.

@danmar danmar merged commit 3813616 into danmar:main Mar 2, 2023
@firewave firewave deleted the notchk-2 branch March 2, 2023 20:54
firewave added a commit to firewave/cppcheck that referenced this pull request Mar 24, 2026
firewave added a commit to firewave/cppcheck that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants