errno is only set on an error. It's not cleared on success. If errno was previously set, the function will always abort(). So you need to do something like:
int saved_errno = errno;
errno = 0;
....
errno = saved_errno;
return aInt;