error: ensure error codes are signed negative ints.

Based on a patch by Robert Nagy <ronag89@gmail.com>.

It makes a difference when the error code is immediately cast
into a larger integer, such as an int64_t.
