Uset errno before testing

Signed-off-by: Michal Čihař <michal@cihar.com>