The first commit moves the initialization of pxIPHeader. This fixes a possible nullpointer dereference.
~The second commit reduces the scope of pxIPHeader and other local variables.~ Dropped.
Test Steps
I am using this CMake hack to compile my project with clang-tidy:
# Setting *_CLANG_TIDY tells CMake to insert itself as a compiler wrapper,
# underneath Ccache, that also runs Clang-tidy. Thus, Clang-tidy is rerun
# whenever the compiler is, as determined by Ninja and Ccache. For Ccache
# invalidation to work when settings are changed, the settings must therefore be
# in the arguments, not some ".clang-tidy" file that Ccache doesn't know about.
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(tidy_checks
-clang-analyzer-security.insecureAPI.*
-clang-analyzer-deadcode.DeadStores
# -clang-analyzer-core.NullDereference
)
string(JOIN "," tidy_checks_str ${tidy_checks})
set(CMAKE_C_CLANG_TIDY
clang-tidy
--use-color
--checks=${tidy_checks_str}
--warnings-as-errors=*,${tidy_checks_str}
)
endif()
Checklist:
[ ] I have tested my changes. No regression in existing tests.
[ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request.
[x] I have run clang-tidy on the changed files to confirm that the changes at least make clang-tidy happy.
Related Issue
1136
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Description
The first commit moves the initialization of pxIPHeader. This fixes a possible nullpointer dereference.
~The second commit reduces the scope of pxIPHeader and other local variables.~ Dropped.
Test Steps
I am using this CMake hack to compile my project with clang-tidy:
Checklist:
Related Issue
1136
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.