Skip to content

Commit

Permalink
pw_tokenizer: Fix decode string size type
Browse files Browse the repository at this point in the history
Clang is unnecessarily strict with its narrowing rules, add a cast
to size_t to avoid using a '-Wno-c++11-narrowing', which could
potentially hide legitimate problems.

Change-Id: I87a9838816b68f69a1fe1d02b06a41d218d49fce
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/98267
Pigweed-Auto-Submit: Karthik Bharadwaj <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
  • Loading branch information
karthik bharadwaj authored and CQ Bot Account committed Jun 16, 2022
1 parent 82e526c commit 5c9007f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pw_tokenizer/decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ DecodedArg StringSegment::DecodeString(

if (arguments.size() - 1 < size) {
status.Update(ArgStatus::kDecodeError);
return DecodedArg(
status,
text_,
arguments.size(),
{reinterpret_cast<const char*>(&arguments[1]), arguments.size() - 1});
return DecodedArg(status,
text_,
arguments.size(),
{reinterpret_cast<const char*>(&arguments[1]),
static_cast<size_t>(arguments.size()) - 1});
}

std::string value(reinterpret_cast<const char*>(&arguments[1]), size);
Expand Down

0 comments on commit 5c9007f

Please sign in to comment.