Fix compilation on GCC 12.5 and the deprecation warning on CMake 3.31.9#23
Fix compilation on GCC 12.5 and the deprecation warning on CMake 3.31.9#23mateuszpsnik-adtran wants to merge 3 commits intomisje:masterfrom
Conversation
CMake versions lower than 3.10 will be deprecated in the future CMake releases.
On GCC 12.5 there was a warning that (due to -Werror) stopped compilation: warning: assuming signed overflow does not occur when simplifying ‘X - Y > 0’ to ‘X > Y’ [-Wstrict-overflow] 168 | if (argc - optind > 0) This commit fixes this warning and enables compilation on GCC 12.5
Fix compilation on GCC 12.5 and the deprecation warning on CMake 3.31.9
|
Hei, Thank you for your contribution! You have added a new feature and option as well in your later commits. Although it is fairly easy to understand their purpose, would you mind adding a bit of context? I will need to update the corresponding deb package, so the more info, the better. Also, what use case made you require this new option? |
b341f4f to
e3a3915
Compare
|
Hey, Sorry for the confusion - I rarely use GitHub nowadays, and I didn't know that this pull request would automatically follow the master branch of my fork. I wanted this PR to have only small build-related changes so that this project compiles again on updated GCC (and without the CMake warning on an updated version). Then, if the feature that I'm working on (that you've already seen, probably) is ready (properly tested on our setup, etc.), I will add another PR in which I will, of course, explain the context and show some examples/outputs to prove that it works properly (tcpdumps, etc.). I'm adding this PR first because I understand you may want to merge the small build-related changes, but not the new feature itself. Now that this PR is back in the form I wanted, I'm looking forward to your feedback. Thank you. |
On GCC 12.5 and using CMake 3.31.9, I got such warnings:
CMake:
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument value. Or, use the ... syntax
to tell CMake that the project requires at least but has been updated
to work with policies introduced by or earlier.
GCC:
warning: assuming signed overflow does not occur when simplifying ‘X - Y > 0’ to ‘X > Y’ [-Wstrict-overflow]
168 | if (argc - optind > 0)
| ~~~~~^~~~~~~~
Due to the -Werror flag, the GCC warning stopped compilation.
After these minor fixes, the project compiles in my environment:
(...)
[ 50%] Building C object CMakeFiles/dhcpoptinj.dir/src/dhcpoptinj.c.o
[ 50%] Building C object CMakeFiles/dhcpoptinj.dir/src/config.c.o
[ 50%] Building C object CMakeFiles/dhcpoptinj.dir/src/dhcp.c.o
[ 66%] Building C object CMakeFiles/dhcpoptinj.dir/src/ipv4.c.o
[ 83%] Building C object CMakeFiles/dhcpoptinj.dir/src/options.c.o
[100%] Linking C executable dhcpoptinj
[100%] Built target dhcpoptinj