Skip to content

Fix compilation on GCC 12.5 and the deprecation warning on CMake 3.31.9#23

Open
mateuszpsnik-adtran wants to merge 3 commits intomisje:masterfrom
mateuszpsnik-adtran:master
Open

Fix compilation on GCC 12.5 and the deprecation warning on CMake 3.31.9#23
mateuszpsnik-adtran wants to merge 3 commits intomisje:masterfrom
mateuszpsnik-adtran:master

Conversation

@mateuszpsnik-adtran
Copy link
Copy Markdown

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

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
@mateuszpsnik-adtran mateuszpsnik-adtran marked this pull request as ready for review April 1, 2026 14:50
@misje
Copy link
Copy Markdown
Owner

misje commented Apr 9, 2026

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?

@mateuszpsnik-adtran
Copy link
Copy Markdown
Author

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.

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