We fucked up errno vs. r two times, let's correct that.
While we are at it, let's handle the error first, like we usually do,
and the clean case without indentation.
(cherry picked from commit 88287615)
(cherry picked from commit 6b48479f)
(cherry picked from commit 9d5e3cb7)