Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0bf3664 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

zip_archive.cc: Use static cast instead of masking

Although ubsan's implicit-unsigned-integer-truncation sanitizer may be
happy, this code still performs an implicit conversion from a wider
width data structure to a narrower width data structure. Rather than
masking the bits, make the conversion explicit. This keeps ubsan happy
as well as addressing a -Wconversion warning.

This change addresses comments from the post-submit review
of a4e54336.

Test: compiles and boots.
Bug: 122975762
Change-Id: I1fa6d6f8a6fcfb93ba9916b7d2b3564ca1d8caf3
parent 55ba959c
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -102,9 +102,8 @@ static uint32_t RoundUpPower2(uint32_t val) {
}

static uint32_t ComputeHash(const ZipString& name) {
  return std::hash<std::string_view>{}(
             std::string_view(reinterpret_cast<const char*>(name.name), name.name_length)) &
         UINT32_MAX;
  return static_cast<uint32_t>(std::hash<std::string_view>{}(
      std::string_view(reinterpret_cast<const char*>(name.name), name.name_length)));
}

static bool isZipStringEqual(const uint8_t* start, const ZipString& zip_string,