Repository navigation
Enable clang-tidy's misc-const-correctness check - #233
Merged
Merged
Conversation
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>
derobins
requested review from
akolliasAMD,
gaoikawa,
jordan-turbofish,
kurtmcmillan,
riley-dixon,
sbates130272 and
zbyrne
as code owners
October 15, 2026 18:58
Contributor
There was a problem hiding this comment.
🟢 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.
Contributor
Security scan found no critical or high findings on lines changed by this pull requestView 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. |
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.
Turn on misc-const-correctness, which was on the TODO list, and fix what it reports:
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.