Pádraig Brady wrote:
On the face of it, setting errno=0 when returning 0 seems correct,
I would say just the opposite. Typically, functions that return 0 on success and -1 (setting errno) on failure, are allowed to set errno to whatever they like on success. So it should not fix any bugs to set errno to 0 here. My guess is that the bugs are in the callers, not here in the callees.
