Refactor includes and fix clang errors/warnings in (MatcherUtils.h, MatcherUtils.cc) generating compilation error during build#13194
Open
grahamsedman wants to merge 2 commits into
Conversation
Revised includes headers to remove the unused tscore/Result.h header and add the tscore/ink_platform.h header.
Remove direct inclusions of ink_platform.h and ink_inet.h as they are pulled in transitively via MatcherUtils.h. Reorder the remaining include statements for better organisation. Update format specifiers in readIntoBuffer to use %zd for ssize_t variables to ensure correct formatting across different platforms. Replace C-style cast with static_cast in unescapifyStr when passing nullptr to strtol to adhere to C++ coding standards.
eeaf214 to
b717414
Compare
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.
This PR addresses specific compilation errors and warnings raised by Clang and Clang-tidy regarding format specifiers and C-style casts in
MatcherUtils.cc.Changes:
Fix Format Specifier Errors (Line 116):
%ldexpectslong, but the provided argumentsread_sizeandfile_sizeare of typessize_t(which maps tointin the compilation environment triggering the error).%zd, which is the correct specifier forssize_t.Fix C-Style Cast Warning (Line 145):
clang-tidy(google-readability-casting) flagged the C-style cast(char **)nullptrinside thestrtolcall.static_cast<char **>(nullptr).Related Files:
src/tscore/MatcherUtils.ccDiff:
Checks:
-Wformat)google-readability-casting)Compilation Errors
/home/grahamsedman/Projects/trafficserver/src/tscore/MatcherUtils.cc:116:78: error: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
116 | Error("%s Only able to read %ld bytes out %ld for %s file", module_name, read_size, file_size, file_path);
| ~~~ ^~~~~~~~~
| %zd