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

Daniel Rodríguez Troitiño via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 10:02:02 PDT 2022


drodriguez added a comment.

My comment about using `size_t` instead are not a blocker, just an opinion.

Whenever this is ready to land, if you need us to land this, please comment so and we will submit.



================
Comment at: llvm/lib/ObjCopy/MachO/MachOWriter.cpp:523-525
+                    std::min(static_cast<ssize_t>(HashReadEnd
+                             - CurrHashReadPosition),
                              static_cast<ssize_t>(CodeSignature.BlockSize)));
----------------
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).


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