[compiler-rt] [scudo][NFC] Explicit type casting to avoid compiler warning (PR #83355)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 15:31:03 PST 2024


https://github.com/ChiaHungDuan created https://github.com/llvm/llvm-project/pull/83355

None

>From cc845be81ddfc5e6623ad9e7d1a9eaedbf5278c2 Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Wed, 28 Feb 2024 23:28:44 +0000
Subject: [PATCH] [scudo][NFC] Explicit type casting to avoid compiler warning

---
 compiler-rt/lib/scudo/standalone/allocator_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/scudo/standalone/allocator_common.h b/compiler-rt/lib/scudo/standalone/allocator_common.h
index 4d39956bf90503..c7c6035f241f45 100644
--- a/compiler-rt/lib/scudo/standalone/allocator_common.h
+++ b/compiler-rt/lib/scudo/standalone/allocator_common.h
@@ -53,7 +53,7 @@ template <class SizeClassAllocator> struct TransferBatch {
   void moveNToArray(CompactPtrT *Array, u16 N) {
     DCHECK_LE(N, Count);
     memcpy(Array, Batch + Count - N, sizeof(Batch[0]) * N);
-    Count -= N;
+    Count -= static_cast<u16>(Count - N);
   }
   u16 getCount() const { return Count; }
   bool isEmpty() const { return Count == 0U; }



More information about the llvm-commits mailing list