diff options
author | Thomas Graf <tgr@lsx.localdomain> | 2008-05-14 15:49:44 (GMT) |
---|---|---|
committer | Thomas Graf <tgr@lsx.localdomain> | 2008-05-14 15:49:44 (GMT) |
commit | 8a3efffa5b3fde252675239914118664d36a2c24 (patch) | |
tree | f8efc71b2bd4736f2a56084efea05d7ee191a422 /lib/route/sch/fifo.c | |
parent | 85f932552e61c5997c1e83fe386098c94d93c273 (diff) | |
download | libnl-8a3efffa5b3fde252675239914118664d36a2c24.zip libnl-8a3efffa5b3fde252675239914118664d36a2c24.tar.gz libnl-8a3efffa5b3fde252675239914118664d36a2c24.tar.bz2 |
Thread-safe error handling
In order for the interface to become more thread safe, the error
handling was revised to no longer depend on a static errno and
error string buffer.
This patch converts all error paths to return a libnl specific
error code which can be translated to a error message using
nl_geterror(int error). The functions nl_error() and
nl_get_errno() are therefore obsolete.
This change required various sets of function prototypes to be
changed in order to return an error code, the most prominent
are:
struct nl_cache *foo_alloc_cache(...);
changed to:
int foo_alloc_cache(..., struct nl_cache **);
struct nl_msg *foo_build_request(...);
changed to:
int foo_build_request(..., struct nl_msg **);
struct foo *foo_parse(...);
changed to:
int foo_parse(..., struct foo **);
This pretty much only leaves trivial allocation functions to
still return a pointer object which can still return NULL to
signal out of memory.
This change is a serious API and ABI breaker, sorry!
Diffstat (limited to 'lib/route/sch/fifo.c')
-rw-r--r-- | lib/route/sch/fifo.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/route/sch/fifo.c b/lib/route/sch/fifo.c index 4f8d202..a8953f9 100644 --- a/lib/route/sch/fifo.c +++ b/lib/route/sch/fifo.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ /** @@ -60,11 +60,11 @@ static int fifo_msg_parser(struct rtnl_qdisc *qdisc) struct tc_fifo_qopt *opt; if (qdisc->q_opts->d_size < sizeof(struct tc_fifo_qopt)) - return nl_error(EINVAL, "FIFO options size mismatch"); + return -NLE_INVAL; fifo = fifo_alloc(qdisc); if (!fifo) - return nl_errno(ENOMEM); + return -NLE_NOMEM; opt = (struct tc_fifo_qopt *) qdisc->q_opts->d_data; fifo->qf_limit = opt->limit; @@ -148,7 +148,7 @@ int rtnl_qdisc_fifo_set_limit(struct rtnl_qdisc *qdisc, int limit) fifo = fifo_alloc(qdisc); if (!fifo) - return nl_errno(ENOMEM); + return -NLE_NOMEM; fifo->qf_limit = limit; fifo->qf_mask |= SCH_FIFO_ATTR_LIMIT; @@ -169,7 +169,7 @@ int rtnl_qdisc_fifo_get_limit(struct rtnl_qdisc *qdisc) if (fifo && fifo->qf_mask & SCH_FIFO_ATTR_LIMIT) return fifo->qf_limit; else - return nl_errno(ENOMEM); + return -NLE_NOATTR; } /** @} */ |