fix: silence -Wnonnull-compare and Botan FFI deprecation warnings - #2446
Closed
ronaldtse wants to merge 1 commit into
Closed
fix: silence -Wnonnull-compare and Botan FFI deprecation warnings#2446ronaldtse wants to merge 1 commit into
ronaldtse wants to merge 1 commit into
Conversation
Two build-warning classes from the v0.18.1 release build:
* rnp_key_store.cpp passed &srckey (address of a Key reference, which is
provably non-null) to RNP_LOG_KEY, whose null guard then tripped
-Wnonnull-compare under GCC. Add an RNP_LOG_KEY_NN variant without the
null check and use it for every &srckey call site; nullable pointers
(primary/added_key) keep the null-checking macro.
* ec.cpp and eddsa.cpp used botan_{privkey,pubkey}_*_get_* helpers
deprecated in Botan 3.x. Use the generic botan_*_view_raw API
(available since Botan 3.6) when available, keeping the legacy calls
for older Botan. A small length-checked view callback is added to
botan_utils.hpp.
3 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2446 +/- ##
==========================================
- Coverage 85.37% 85.37% -0.01%
==========================================
Files 126 126
Lines 22790 22775 -15
==========================================
- Hits 19458 19445 -13
+ Misses 3332 3330 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Closing — superseded by #2448 which migrates Botan backend to FFI, resolving the deprecation warnings this PR was silencing. Combined to reduce review overhead. |
ronaldtse
added a commit
that referenced
this pull request
Aug 5, 2026
…s PR Merges the -Wnonnull-compare fix (RNP_LOG_KEY_NN macro + rnp_key_store usage) and the compile-time-warnings.adoc policy doc from the now-closed #2446 and #2428 into this PR, since the FFI migration naturally resolves the deprecation warnings those PRs were patching. Reduces review overhead: one PR covers the FFI migration + the warning policy + the nonnull-compare fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two build-warning classes reported in the v0.18.1 release build (GCC).
1.
-Wnonnull-compareinsrc/librekey/rnp_key_store.cppRNP_LOG_KEY(msg, &srckey)expanded toif (!(&srckey)), but&srckeyis the address of aKey&reference and is provably non-null, so GCC flagged every such call site. Added anRNP_LOG_KEY_NNvariant (no null check) insrc/lib/logging.hand switched all&srckeycall sites to it. Nullable-pointer sites (primary,added_key) keep the null-checkingRNP_LOG_KEY. Verified there are no remainingRNP_LOG_KEY(..., &ref)call sites in the tree.2.
-Wdeprecated-declarationsinsrc/lib/crypto/ec.cppandsrc/lib/crypto/eddsa.cppbotan_privkey_x25519_get_privkey,botan_pubkey_x25519_get_pubkey, andbotan_privkey_ed25519_get_privkeyare deprecated in Botan 3.x. Switched to the genericbotan_privkey_view_raw/botan_pubkey_view_rawAPI (available since Botan 3.6) under aBOTAN_VERSION_CODE >= 3.6.0guard, keeping the legacy calls for older Botan (2.x and 3.0–3.5, where the helpers are not deprecated andview_rawdoes not exist). A small length-checked view callback (rnp_botan_view_bin) and descriptor (rnp_botan_view_buf) live insrc/lib/crypto/botan_utils.hpp; the per-site descriptors are declared inside the#ifso they don't trigger-Wunused-variableon older Botan.A codebase-wide sweep confirmed the remaining deprecated Botan FFI calls (
botan_key_wrap3394/botan_key_unwrap3394inecdh.cpp, the_encSM2 loaders) are already behindCRYPTO_BACKEND_BOTAN3guards or use the non-deprecated overloads, and that ed448/x448 paths do not use the deprecated getters.Notes
ec.cpp(aroundBotan::EC_Group::from_name, underENABLE_CRYPTO_REFRESH) is unrelated to these warning classes and intentionally left out of scope.Test plan
-DCRYPTO_BACKEND=botan3against Botan 3.12;librnp-obj,rnpkeys, andrnpbuild with zero warnings/errors (Apple Clang 15).ec.cpp,eddsa.cpp,rnp_key_store.cppcompile clean.view_rawcall sites.-Wnonnull-compareand-Wdeprecated-declarationsare gone for these files.