[PATCH] D128117: [ObjCopy] Fix type mismatch in writeCodeSignatureData()

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 16:06:02 PDT 2022


alexander-shaposhnikov added inline comments.


================
Comment at: llvm/lib/ObjCopy/MachO/MachOWriter.cpp:523-525
+                    std::min(static_cast<ssize_t>(HashReadEnd
+                             - CurrHashReadPosition),
                              static_cast<ssize_t>(CodeSignature.BlockSize)));
----------------
drodriguez wrote:
> I am sorry for the initial blunder and sorry for breaking this for 32 bits platforms.
> 
> I was wondering why we did this original. The `StringRef` constructor needs `size_t` for its second argument. `BlockSize` is already `size_t`. Because of the `while` loop check `HashReadEnd - CurrHashReadPosition` has to be positive. I wonder if the right thing here is casting to `size_t`.
> 
> (`ssize_t` has a weird range. It is not a "signed `size_t`", but a `size_t` that allows `-1` to be returned. But in any case, there's no negative numbers being handled here, it is just a `ptrdiff_t` which we know to be positive).
I suspect it might originate from https://github.com/llvm/llvm-project/blob/5ba0a9571b3ee3bc76f65e16549012a440d5a0fb/lld/MachO/SyntheticSections.cpp#L1243
it appears to be safe to cast to size_t 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128117/new/

https://reviews.llvm.org/D128117



More information about the llvm-commits mailing list