[PATCH] D128117: [ObjCopy] Fix type mismatch in writeCodeSignatureData()
Joshua Root via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 18 04:10:09 PDT 2022
jmroot created this revision.
jmroot added reviewers: alexander-shaposhnikov, drodriguez.
Herald added subscribers: abrachet, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a project: All.
jmroot requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
The result of pointer subtraction is of type ptrdiff_t, which is not necessarily the same underlying type as ssize_t. This can lead to a compilation error since std::min requires both parameters to be the same type.
Fixes: https://github.com/llvm/llvm-project/issues/54846
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128117
Files:
llvm/lib/ObjCopy/MachO/MachOWriter.cpp
Index: llvm/lib/ObjCopy/MachO/MachOWriter.cpp
===================================================================
--- llvm/lib/ObjCopy/MachO/MachOWriter.cpp
+++ llvm/lib/ObjCopy/MachO/MachOWriter.cpp
@@ -520,7 +520,8 @@
uint8_t *CurrHashWritePosition = HashWriteStart;
while (CurrHashReadPosition < HashReadEnd) {
StringRef Block(reinterpret_cast<char *>(CurrHashReadPosition),
- std::min(HashReadEnd - CurrHashReadPosition,
+ std::min(static_cast<ssize_t>(HashReadEnd
+ - CurrHashReadPosition),
static_cast<ssize_t>(CodeSignature.BlockSize)));
SHA256 Hasher;
Hasher.update(Block);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128117.438110.patch
Type: text/x-patch
Size: 699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220618/834627d7/attachment.bin>
More information about the llvm-commits
mailing list