diff options
author | Tom Rini <trini@konsulko.com> | 2019-11-01 09:23:21 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-11-01 09:23:21 -0400 |
commit | 82679624f9aa6d1be733c46f3555d5166b6f5b72 (patch) | |
tree | 8a99cf79bc520b833e155094ef134c0526b1f005 /lib/errno_str.c | |
parent | 412326d1bc2d346d7b4faad6fa547eaf065681a2 (diff) | |
parent | 5d80a1a93d42c8325d65516cc654ff6a9ceec58a (diff) |
Merge branch '2019-10-30-master-imports'
- Migrate test.py to use python3 and current pytest.
- NVMe bugfixes
- Assorted other fixes
- Android AVB updates.
Diffstat (limited to 'lib/errno_str.c')
-rw-r--r-- | lib/errno_str.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/errno_str.c b/lib/errno_str.c index 0ba950e9703..2e5f4a887d5 100644 --- a/lib/errno_str.c +++ b/lib/errno_str.c @@ -13,7 +13,7 @@ static const char * const errno_message[] = { ERRNO_MSG(0, "Success"), ERRNO_MSG(EPERM, "Operation not permitted"), - ERRNO_MSG(ENOEN, "No such file or directory"), + ERRNO_MSG(ENOENT, "No such file or directory"), ERRNO_MSG(ESRCH, "No such process"), ERRNO_MSG(EINTR, "Interrupted system call"), ERRNO_MSG(EIO, "I/O error"), @@ -26,7 +26,7 @@ static const char * const errno_message[] = { ERRNO_MSG(ENOMEM, "Out of memory"), ERRNO_MSG(EACCES, "Permission denied"), ERRNO_MSG(EFAULT, "Bad address"), - ERRNO_MSG(ENOTBL, "Block device required"), + ERRNO_MSG(ENOTBLK, "Block device required"), ERRNO_MSG(EBUSY, "Device or resource busy"), ERRNO_MSG(EEXIST, "File exists"), ERRNO_MSG(EXDEV, "Cross-device link"), @@ -136,6 +136,8 @@ static const char * const errno_message[] = { ERRNO_MSG(EDQUOT, "Quota exceeded"), ERRNO_MSG(ENOMEDIUM, "No medium found"), ERRNO_MSG(EMEDIUMTYPE, "Wrong medium type"), + /* Message for unsupported error numbers */ + ERRNO_MSG(0, "Unknown error"), }; const char *errno_str(int errno) @@ -143,5 +145,9 @@ const char *errno_str(int errno) if (errno >= 0) return errno_message[0]; - return errno_message[abs(errno)]; + errno = -errno; + if (errno >= ARRAY_SIZE(errno_message)) + errno = ARRAY_SIZE(errno_message) - 1; + + return errno_message[errno]; } |