Hello Alexey Serbin, Kudu Jenkins,
I'd like you to reexamine a change. Please visit
http://gerrit.cloudera.org:8080/23057
to look at the new patch set (#2).
Change subject: [compile] Fix compiler warnings about -Wrange-loop-construct
......................................................................
[compile] Fix compiler warnings about -Wrange-loop-construct
This commit resolves multiple instances of the
`-Wrange-loop-construct` warning across various tests. The
warnings were caused by using `const std::string&` as the
loop variable when iterating over brace-enclosed initializer
lists of string literals (i.e., `const char*`).
In such cases, the compiler generates temporary `std::string`
objects, and binding a reference to them is potentially unsafe
and triggers compiler warnings.
The warnings were of the form:
warning: loop variable '...' of type 'const string&' binds
to a temporary constructed from type 'const char* const'
[-Wrange-loop-construct]
To address this:
- Loops are updated to use `const char*` (`const auto*` or
`const auto* const`) to avoid unnecessary temporaries.
- When string operations are needed (e.g., `.empty()`,
comparisons with `std::string`), explicit `std::string`
objects are constructed inside the loop body.
- In one case (`TestGetFlags`), `const char*` was converted
to `std::string` early in the loop body to preserve logic
requiring string-based comparison.
This change eliminates warnings while maintaining safe and
readable code, and avoids unnecessary string copies when not
needed.
Change-Id: I32a9a043e7aade2c2c879472c13cbf2641daa7f3
---
M src/kudu/consensus/quorum_util-test.cc
M src/kudu/tools/kudu-tool-test.cc
M src/kudu/tserver/tablet_server-test.cc
3 files changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/57/23057/2
--
To view, visit http://gerrit.cloudera.org:8080/23057
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I32a9a043e7aade2c2c879472c13cbf2641daa7f3
Gerrit-Change-Number: 23057
Gerrit-PatchSet: 2
Gerrit-Owner: KeDeng <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)