bytestring icon indicating copy to clipboard operation
bytestring copied to clipboard

Audit `foreign import ccall` types

Open clyring opened this issue 2 years ago • 0 comments

In this comment it was noticed that we have a mismatch between the actual C prototype of sbs_elem_index and the foreign import in our Haskell code:

ptrdiff_t
sbs_elem_index(const void *s,
            int c,
            size_t n)
{ // ...
foreign import ccall unsafe "static sbs_elem_index"
    c_elem_index :: ByteArray# -> Word8 -> CSize -> IO CPtrdiff

Notice that for the second argument we have Word8 on the Haskell side and int on the C side.

I will audit our foreign imports for similar mistakes.

clyring avatar Feb 01 '24 17:02 clyring