tokenrove / tsdl-mixer

SDL2_mixer bindings to go with Tsdl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zero_to_ok ?

zapashcanon opened this issue · comments

Hi,

Looking at the source code I saw:

let zero_to_ok =
  let read = function 0 -> Ok () | _ -> Ok () in
view ~read ~write:write_never int

Which is used here for instance:

let open_audio =
foreign "Mix_OpenAudio" (int @-> int @-> int @-> int @-> returning zero_to_ok)

So, I checked, and, it appears from the doc that the C function Mix_OpenAudio:

Returns: 0 on success, -1 on errors

Thus, I'm wondering, am I missing something here ? I'm not familiar with bindings. But still, looks like it should be:

let zero_to_ok =
  let read = function 0 -> Ok () | _ -> error () in (* not returning Ok () when we don't have 0 *)
view ~read ~write:write_never int

Good catch! Probably a copy-paste error from nonzero_to_ok. For robust usage of any of these bindings, properly all the error paths should be tested. That definitely hasn't happened yet.

Thanks! Let me know if this blocks your usage of the library and I can make a release; otherwise I'll wait for more changes (and perhaps tests) to accumulate.

You're welcome !

Let me know if this blocks your usage of the library

No, I was just looking how to write bindings, so not a problem for me.