Changeset 9af1c61 in mainline for uspace/lib/c/generic/str_error.c
- Timestamp:
- 2017-12-05T14:52:22Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- addbce4
- Parents:
- 82d515e9
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-05 14:50:38)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-05 14:52:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str_error.c
r82d515e9 r9af1c61 41 41 #define NOERR_LEN 64 42 42 43 // TODO: this file should be generated from errno declarations 44 45 static const char* err_name[] = { 46 "EOK", 47 "ENOENT", 48 "ENOMEM", 49 "ELIMIT", 50 "EREFUSED", 51 "EFORWARD", 52 "EPERM", 53 "EHANGUP", 54 "EPARTY", 55 "EEXIST", 56 "EBADMEM", 57 "ENOTSUP", 58 "EADDRNOTAVAIL", 59 "ETIMEOUT", 60 "EINVAL", 61 "EBUSY", 62 "EOVERFLOW", 63 "EINTR" 64 }; 65 43 66 static const char* err_desc[] = { 44 67 "No error", 45 68 "No such entry", 46 69 "Not enough memory", 47 "Limit exceeded", 70 "Limit exceeded", 48 71 "Connection refused", 49 72 "Forwarding error", … … 64 87 static fibril_local char noerr[NOERR_LEN]; 65 88 66 const char *str_error(const int e) 89 const char *str_error_name(errno_t e) 90 { 91 if ((e <= 0) && (e >= MIN_ERRNO)) 92 return err_name[-e]; 93 94 /* Ad hoc descriptions of error codes interesting for USB. */ 95 // FIXME: integrate these as first-class error values 96 switch (e) { 97 case ENOFS: 98 return "ENOFS"; 99 case EBADCHECKSUM: 100 return "EBADCHECKSUM"; 101 case ESTALL: 102 return "ESTALL"; 103 case EAGAIN: 104 return "EAGAIN"; 105 case EEMPTY: 106 return "EEMPTY"; 107 default: 108 break; 109 } 110 111 snprintf(noerr, NOERR_LEN, "(%d)", (int)e); 112 return noerr; 113 } 114 115 const char *str_error(errno_t e) 67 116 { 68 117 if ((e <= 0) && (e >= MIN_ERRNO)) … … 86 135 } 87 136 88 snprintf(noerr, NOERR_LEN, "Unk own error code %d",e);137 snprintf(noerr, NOERR_LEN, "Unknown error code (%d)", (int)e); 89 138 return noerr; 90 139 }
Note:
See TracChangeset
for help on using the changeset viewer.