Add SECP256K1_WARN_UNUSED_RESULT to all relevant static int functions #1876

pull shivv23 wants to merge 3 commits into bitcoin-core:master from shivv23:add-warn-unused-result changing 38 files +197 −193
  1. shivv23 commented at 7:29 PM on June 18, 2026: none

    Annotate all static int functions in the library (non-test code) with SECP256K1_WARN_UNUSED_RESULT so that compilers can warn when return values are accidentally discarded. This covers ~140 functions across all modules.

    Changes:

    • Add SECP256K1_WARN_UNUSED_RESULT to field, scalar, group, eckey, ecmult, ecdsa, int128 utility functions and all module header/impl files
    • Fix call sites where return values were being discarded:
      • secp256k1_ec_pubkey_combine: check pubkey_load return
      • secp256k1_ecdh: check pubkey_load return
      • secp256k1_ellswift_swiftec_var, ellswift_xdh: use assignment pattern
      • bench_internal.c, bench_ecmult.c, test files: wrap in CHECK()
    • Exclude scalar_add and scalar_cond_negate whose returns are intentionally informational/redundant at all existing call sites

    See #1610 for prior discussion.

  2. Add SECP256K1_WARN_UNUSED_RESULT to all relevant static int functions
    Annotate all static int functions in the library (non-test code) with
    SECP256K1_WARN_UNUSED_RESULT to catch bugs where return values are
    accidentally discarded. This covers ~140 functions across all modules.
    
    Key changes:
    - Add WARN_UNUSED_RESULT to field, scalar, group, eckey, ecmult,
      ecdsa, int128 utility functions and all module functions
    - Fix 4 call sites where return values were being ignored:
      - secp256k1_ec_pubkey_combine: check pubkey_load return
      - secp256k1_ecdh: check pubkey_load return
      - secp256k1_ellswift_swiftec_var: VERIFY_CHECK ge_set_xo_var
      - ellswift_xdh: (void) cast for ecmult_const_xonly with known_on_curve=1
    - Do not annotate scalar_add or scalar_cond_negate whose returns are
      intentionally informational/redundant at all call sites
    b03ce92afa
  3. Fix ignored return values that caused CI failures 6344822ac3
  4. gatleas17 commented at 12:23 AM on June 19, 2026: none

    Ñla

  5. Fix ignored return values in test/bench files 2c77462563
  6. shivv23 closed this on Jun 19, 2026

  7. real-or-random added the label assurance on Jun 19, 2026
  8. real-or-random added the label tweak/refactor on Jun 19, 2026
  9. real-or-random added the label meta/development on Jun 19, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-06-20 23:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me