Skip to content

Avoid returning enum in boolean context - #2364

Merged
ronaldtse merged 1 commit into
rnpgp:release/0.xfrom
dkg:return-boolean
Jul 22, 2026
Merged

ronaldtse merged 1 commit into
rnpgp:release/0.xfrom
dkg:return-boolean

Conversation

@dkg

@dkg dkg commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Without this fix, when compiling with ENABLE_CRYPTO_REFRESH, we see:

…/src/lib/enc_material.cpp: In member function ‘virtual bool pgp::X25519EncMaterial::parse(pgp_packet_body_t&)’:
…/src/lib/enc_material.cpp:154:20: warning: enum constant in boolean context [-Wint-in-bool-context]
  154 |             return RNP_ERROR_BAD_FORMAT;
      |                    ^~~~~~~~~~~~~~~~~~~~
make[3]: Leaving directory '…/build'

@codecov

codecov Bot commented Oct 9, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.46%. Comparing base (bf89f0b) to head (dcaa3a1).
⚠️ Report is 15 commits behind head on release/0.x.

Additional details and impacted files
@@             Coverage Diff              @@
##           release/0.x    #2364   +/-   ##
============================================
  Coverage        85.46%   85.46%           
============================================
  Files              126      126           
  Lines            22710    22710           
============================================
  Hits             19408    19408           
  Misses            3302     3302           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TJ-91

TJ-91 commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

FYI, this, among other things, is also being fixed in PR #2355

@ronaldtse

Copy link
Copy Markdown
Contributor

Verified against current main: the same spot in X25519EncMaterial::parse() now already does 'return false;' (the whole function was reworked to return bool properly by the crypto-refresh/PQC refactoring, e.g. 2dcae85 and follow-ups). This PR is a no-op against current main and can probably be closed as superseded. I left it unmerged/unclosed for the author/maintainers to confirm.

Without this fix, when compiling with `ENABLE_CRYPTO_REFRESH`, we see:

```
…/src/lib/enc_material.cpp: In member function ‘virtual bool pgp::X25519EncMaterial::parse(pgp_packet_body_t&)’:
…/src/lib/enc_material.cpp:154:20: warning: enum constant in boolean context [-Wint-in-bool-context]
  154 |             return RNP_ERROR_BAD_FORMAT;
      |                    ^~~~~~~~~~~~~~~~~~~~
make[3]: Leaving directory '…/build'
```
@ronaldtse

Copy link
Copy Markdown
Contributor

Correction to my earlier comment: on main this is indeed already fixed, but this PR targets release/0.x where the issue is still present. Rebased onto release/0.x and extended the fix to the identical case in MlkemEcdhEncMaterial::parse (same 'return RNP_ERROR_BAD_FORMAT' in a bool function, line 205). Verified locally on the release/0.x base.

@ronaldtse

Copy link
Copy Markdown
Contributor

Just need one more approval!

@ronaldtse
ronaldtse requested a review from ni4 July 19, 2026 10:53

@ni4 ni4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ronaldtse
ronaldtse merged commit ba06179 into rnpgp:release/0.x Jul 22, 2026
107 of 121 checks passed
@ronaldtse

Copy link
Copy Markdown
Contributor

Thank you @dkg @ni4 !

@ronaldtse

Copy link
Copy Markdown
Contributor

@dkg FYI we have ported your patches to the main branch at #2402 as well. Thank you!

@ronaldtse

Copy link
Copy Markdown
Contributor

Merging with 2 approvals (ni4, ronaldtse). Thank you @dkg for the contribution, and @ni4 for the review!

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.

4 participants