Set errno for all error return cases.

Test: Updated unit tests pass.
Change-Id: I2c1f14ed44ce144a46cb2866c146fca89a05539e
2 files changed