diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-06-04 19:25:26 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-06-04 19:25:26 -0400 |
commit | 4916c3ba7e3dbefbddb8c5ba8370092ce1a634fb (patch) | |
tree | 623f8d6fc0dae590f29eca86ffb00af70e9a41c4 /src/uv_link_t.c | |
parent | 79d44e403c15b1cfe08f317f17ad20f4814ae4c9 (diff) | |
download | uv_link_t-4916c3ba7e3dbefbddb8c5ba8370092ce1a634fb.tar.gz |
api: uv_link_errno
Diffstat (limited to 'src/uv_link_t.c')
-rw-r--r-- | src/uv_link_t.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/uv_link_t.c b/src/uv_link_t.c index 696dd15..32c676e 100644 --- a/src/uv_link_t.c +++ b/src/uv_link_t.c @@ -221,21 +221,42 @@ int uv_link_unchain(uv_link_t* from, uv_link_t* to) { } -const char* uv_link_strerror(uv_link_t* link, int err) { +int uv_link_errno(uv_link_t** link, int err) { unsigned int prefix; int local_err; + uv_link_t* p; - if (err >= UV_ERRNO_MAX) - return uv_strerror(err); + if (err >= UV_ERRNO_MAX) { + *link = NULL; + return err; + } prefix = (-err) & kErrorPrefixMask; local_err = -((-err) & kErrorValueMask); - for (; link != NULL; link = link->parent) - if (prefix == link->err_prefix) - return link->methods->strerror(link, local_err); + for (p = *link; p != NULL; p = p->parent) { + if (prefix == p->err_prefix) { + *link = p; + return local_err; + } + } + + *link = NULL; + return err; +} + + +const char* uv_link_strerror(uv_link_t* link, int err) { + int local_err; + + if (err >= UV_ERRNO_MAX) + return uv_strerror(err); + + local_err = uv_link_errno(&link, err); + if (link == NULL) + return NULL; - return NULL; + return link->methods->strerror(link, local_err); } |