Skip to content

Conversation

@eddyashton
Copy link
Member

@eddyashton eddyashton commented Nov 12, 2025

While we're improving clang-tidy coverage (#7449, #7451) and adding a lot of [[nodiscard]] attributes I realised these aren't having the desired impact. Because we're also compiling with -Wno-unused, and ignoring all sorts of unused things.

I've fiddled with a few options, and I think what we actually want is -Wno-unused-parameter (because you have to implement a signature, but sometimes an argument isn't for you! Removing the name or adding an attribute are both ugly band-aids), and -Wno-unused-function (because we have lots of header-defined static functions used in some compilation units but not others. Would be great to find which are truly globally unused, but that's harder).

In practice this mostly finds unused lambda captures ([this] -> []), a few unused variables and fields (I think missed during refactors or block copy-pastes), and a few unchecked results of JSWrappedValue::set... calls. I've added check-and-throw blocks so the latter compile, but I think this is ugly; if no-one wants the return values, then we should probably stop returning them entirely, and simply swallow-or-throw within the set... call itself. I've now added [[nodiscard]] to ALL the set functions, and wrapped all call-points in a new JS_CHECK_OR_THROW macro

Copilot AI review requested due to automatic review settings November 12, 2025 13:42
@eddyashton eddyashton requested a review from a team as a code owner November 12, 2025 13:42
Copilot finished reviewing on behalf of eddyashton November 12, 2025 13:47
@achamayou achamayou mentioned this pull request Nov 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves compiler warning coverage by replacing the broad -Wno-unused flag with more targeted -Wno-unused-parameter and -Wno-unused-function flags. This enables detection of genuinely unused variables, fields, and lambda captures while still allowing unused function parameters (required by interface signatures) and unused static header functions.

  • Removes unused lambda captures (primarily [this] where the lambda body doesn't use member variables/functions)
  • Removes unused local variables and fields identified by the stricter warning settings
  • Adds error checking for some previously unchecked JSWrappedValue::set... return values

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
cmake/preproject.cmake Replaces -Wno-unused with more specific -Wno-unused-parameter and -Wno-unused-function to enable better unused code detection
src/tasks/ordered_tasks.cpp Removes unused [this] lambda capture where only the action parameter is used
src/quic/quic_session.h Removes unused written variable that accumulated bytes written but wasn't used
src/node/rpc/node_frontend.h Removes unused [this] captures from multiple lambdas and unused local variables config and service_config
src/node/rpc/jwt_management.h Removes unused issuer_constraints from lambda capture list (still used elsewhere in the function)
src/node/quote.cpp Removes unused digest variable
src/node/node_state.h Removes unused service_config local variable
src/node/gov/handlers/proposals.h Adds error checking for set_bool() return value
src/kv/store.h Removes unused fields size_since_chunk and chunk_threshold
src/kv/serialised_entry_format.h Adds [[maybe_unused]] to max_entry_size constant (used only in assertions)
src/js/registry.cpp Removes unused [this] capture and unused rt variable
src/js/extensions/ccf/request.cpp Adds error checking for multiple set() and set_null() return values when populating JS objects
src/js/extensions/ccf/historical.cpp Removes unused view and seqno variables
src/js/extensions/ccf/crypto.cpp Removes unused exception variable (though this introduces a bug)
src/endpoints/authentication/cose_auth.cpp Removes unused gov_msg_proposal_created_at variable
src/crypto/csr.h Removes unused icrt variable
samples/apps/programmability/programmability.cpp Removes unused [this] lambda capture
samples/apps/logging/logging.cpp Removes many unused [this] lambda captures and unused make_handle lambda function
samples/apps/basic/basic.cpp Removes unused [this] lambda capture

@eddyashton eddyashton marked this pull request as draft November 12, 2025 15:01
@eddyashton
Copy link
Member Author

@copilot review this PR again now it has been updated.

@eddyashton eddyashton marked this pull request as ready for review November 13, 2025 10:30
@achamayou achamayou merged commit a906943 into microsoft:main Nov 13, 2025
17 checks passed
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