Skip to content

Enable clang-tidy's misc-const-correctness check - #233

Merged
derobins merged 1 commit into
developfrom
derobins/clang_tidy_const
Oct 15, 2026
Merged

derobins merged 1 commit into
developfrom
derobins/clang_tidy_const

Conversation

@derobins

Copy link
Copy Markdown
Collaborator

Turn on misc-const-correctness, which was on the TODO list, and fix what it reports:

  • Declare const the locals that are never changed, in the library, the MinIO bridge, the examples, and the tests
  • Make isDevicePointer()'s pointer and the RDMA test server's ibv_mr pointers point to const
  • Give RcConnection const and non-const overloads of qp() and cq(). A const connection hands out a const QP and CQ, so the functions that change the QP's state or poll its CQ take a non-const connection

The check allows hipObj::ApiGuard and std::scoped_lock, since a lock guard is only declared for what its constructor and destructor do.

hipObjInit()'s config and the ops of hipObjGet() and hipObjPut() are only read, but the public header keeps them pointers to non-const to match cuObject's API, so their definitions suppress the check. BufferMap's entry and mr, and two pointers in test-api-args.cpp, also suppress it: clang-tidy doesn't see them moved through try_emplace() or passed through function pointers.

The examples' .clang-tidy turns off the check's parameter analysis, since callbacks have to match libraries' prototypes, such as libcurl's CURLOPT_HEADERFUNCTION, and the examples don't carry suppressions.

The "Not wanted" section of .clang-tidy now says to turn those checks on now and then, such as before a release, and fix what's easy to fix.

Turn on misc-const-correctness, which was on the TODO list, and fix
what it reports:

- Declare const the locals that are never changed, in the library, the
  MinIO bridge, the examples, and the tests
- Make isDevicePointer()'s pointer and the RDMA test server's ibv_mr
  pointers point to const
- Give RcConnection const and non-const overloads of qp() and cq(). A
  const connection hands out a const QP and CQ, so the functions that
  change the QP's state or poll its CQ take a non-const connection

The check allows hipObj::ApiGuard and std::scoped_lock, since a lock
guard is only declared for what its constructor and destructor do.

hipObjInit()'s config and the ops of hipObjGet() and hipObjPut() are
only read, but the public header keeps them pointers to non-const to
match cuObject's API, so their definitions suppress the check.
BufferMap's entry and mr, and two pointers in test-api-args.cpp, also
suppress it: clang-tidy doesn't see them moved through try_emplace()
or passed through function pointers.

The examples' .clang-tidy turns off the check's parameter analysis,
since callbacks have to match libraries' prototypes, such as libcurl's
CURLOPT_HEADERFUNCTION, and the examples don't carry suppressions.

The "Not wanted" section of .clang-tidy now says to turn those checks
on now and then, such as before a release, and fix what's easy to fix.

Co-authored-by: Claude <noreply@anthropic.com>

Copilot AI 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.

🟢 Approval recommended

Static review found no blocking issues in these focused const-correctness changes; builds and tests were not run.

0 open findings

What changed in this PR

Enables clang-tidy’s const-correctness check across hipObject while preserving public API signatures.

Changes:

  • Marks unchanged locals and read-only pointers as const.
  • Adds const and non-const RDMA connection accessors.
  • Configures targeted exceptions for guards, callbacks, and analysis limitations.
File Description
test/​unit/​test-transport.cpp Const-qualifies transport test locals.
test/​unit/​test-thread-safety.cpp Const-qualifies results and token ownership.
test/​unit/​test-staging.cpp Makes the buffer helper const.
test/​unit/​test-seams.cpp Makes API results const.
test/​unit/​test-s3-curl-ops.cpp Const-qualifies HTTP test locals.
test/​unit/​test-s3-control.cpp Makes reply loop values const.
test/​unit/​test-rdma-token.cpp Const-qualifies tokens and encoded strings.
test/​unit/​test-parse-number.cpp Makes base loop values const.
test/​unit/​test-http-server.cpp Makes timing calculations const.
test/​unit/​test-api-args.cpp Adds const locals and targeted suppressions.
test/​integration/​rdma-test-server/​rdma_server.cpp Uses read-only memory-registration pointers.
test/​integration/​rdma-test-server/​main.cpp Makes lookup iterators const.
test/​integration/​rdma-test-server/​http_server.cpp Const-qualifies HTTP handling locals.
src/​state.cpp Makes runtime results const.
src/​rdma/​transport.h Adds const-aware QP and CQ accessors.
src/​rdma/​transport.cpp Const-qualifies transport locals.
src/​rdma/​token.cpp Makes decoded tokens and formatting results const.
src/​hipobj.cpp Adds const access and API-signature suppressions.
src/​common/​rdma-topology.cpp Const-qualifies topology lookup locals.
src/​buffer.cpp Adds const qualifiers and ownership-transfer suppressions.
integrations/​minio-cpp/​test/​test-rdma-header.cpp Makes the encoded token const.
integrations/​minio-cpp/​src/​rdma.cpp Const-qualifies request and response locals.
integrations/​minio-cpp/​src/​client.cpp Const-qualifies client operation locals.
integrations/​minio-cpp/​examples/​getput-rdma.cpp Const-qualifies example locals.
examples/​s3_curl_ops.cpp Adds const locals and read-only callback state access.
examples/​put-object.cpp Makes sizes and resource owners const.
examples/​get-object.cpp Makes sizes and resource owners const.
examples/​.clang-tidy Disables parameter analysis for examples.
.clang-tidy Enables the check with guard exceptions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

@derobins
derobins merged commit 2ea01ce into develop Oct 15, 2026
31 checks passed
@derobins
derobins deleted the derobins/clang_tidy_const branch October 15, 2026 19:12
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