Skip to content

fix(clang-tidy): drop redundant c_str()/data() calls - #1225

Merged
castler merged 1 commit into
eclipse-score:mainfrom
castler:fix_readability_redundant_string_cstr
Oct 2, 2026
Merged

castler merged 1 commit into
eclipse-score:mainfrom
castler:fix_readability_redundant_string_cstr

Conversation

@castler

@castler castler commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 5 readability-redundant-string-cstr findings (shared_memory_resource.cpp x2, configuration_json_parsing_strategy.cpp, tracing_filter_config.cpp x2) by passing the std::string directly instead of .c_str()/.data().

Verification

  • clang-tidy: no remaining findings for this check
  • bazel build //score/... and bazel test //score/memory/... //score/mw/com/impl/... pass

@castler

castler commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

I personally think, we should rather deactivate the check...as it does not provide any value to me.

Resolve all 5 readability-redundant-string-cstr findings by passing the
std::string directly where it converts implicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@limdor

limdor commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

I personally think, we should rather deactivate the check...as it does not provide any value to me.

I would agree with clang tidy change, but the I do not think it is well explain and the reason might be different than the checker claim.
The problem is that if you call .data() or .c_str() you loose any length information. The string needs to be reconstructed with a new lookup for a null termination character. If this would be a string_view it would be worst, because there is no guarantee on being null terminated. For this second reason, in some other projects I was even flagging every call to .data() and c_str because most of the time there is a better safer alternative.
I would just accept the change and leave the checker.

@castler
castler marked this pull request as ready for review October 2, 2026 06:41
@castler
castler added this pull request to the merge queue Oct 2, 2026
Merged via the queue into eclipse-score:main with commit b63311c Oct 2, 2026
18 checks passed
@castler
castler deleted the fix_readability_redundant_string_cstr branch October 2, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants