[scudo] Explicit casting for u16 arithmetic operation
authorChia-hung Duan <chiahungduan@google.com>
Fri, 7 Jul 2023 19:57:47 +0000 (19:57 +0000)
committerChia-hung Duan <chiahungduan@google.com>
Fri, 7 Jul 2023 19:58:02 +0000 (19:58 +0000)
This fixes the werror from https://lab.llvm.org/buildbot/#/builders/165/builds/38829

Reviewed By: enh

Differential Revision: https://reviews.llvm.org/D154733

compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h

index c2fb3e7..0fbc02d 100644 (file)
@@ -553,7 +553,7 @@ private:
         // TODO(chiahungduan): Avoid the use of push_back() in `Batches` of
         // BatchClassId.
         BG->Batches.push_front(CurBatch);
-        UnusedSlots = BG->MaxCachedPerBatch - 1;
+        UnusedSlots = static_cast<u16>(BG->MaxCachedPerBatch - 1);
       }
       // `UnusedSlots` is u16 so the result will be also fit in u16.
       const u16 AppendSize = static_cast<u16>(Min<u32>(UnusedSlots, Size - I));
index df4e893..807aeab 100644 (file)
@@ -665,7 +665,7 @@ private:
         // TODO(chiahungduan): Avoid the use of push_back() in `Batches` of
         // BatchClassId.
         BG->Batches.push_front(CurBatch);
-        UnusedSlots = BG->MaxCachedPerBatch - 1;
+        UnusedSlots = static_cast<u16>(BG->MaxCachedPerBatch - 1);
       }
       // `UnusedSlots` is u16 so the result will be also fit in u16.
       const u16 AppendSize = static_cast<u16>(Min<u32>(UnusedSlots, Size - I));