Ok then, didn't know about the asserts being stripped on some builds. It would have been misleading if I check for -1 even though this condition can never be reached.

This branch looks fine for me, then. I definitely prefer returning -1 instead of 0. You probably can construct weird cases where a negative return values makes existing code behave strangely, but in those cases the code isn't checking the return value of the read call and gets unexpected results anyway.