summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-10 09:02:36 (GMT)
committerThomas Haller <thaller@redhat.com>2018-10-10 09:02:46 (GMT)
commita90256de2f97dbd6b9387e52512ef43e109e1503 (patch)
treeae36529316f7a4f2671b095b9dcdf16d33883d77 /lib
parentc9b28170e7199b3ba63a73c7dad7c2eacab46e72 (diff)
downloadlibnl-a90256de2f97dbd6b9387e52512ef43e109e1503.zip
libnl-a90256de2f97dbd6b9387e52512ef43e109e1503.tar.gz
libnl-a90256de2f97dbd6b9387e52512ef43e109e1503.tar.bz2
route/tc: return error code from rtnl_tc_get_chain()
Our API is unfortunately not consistent about this. However, in general, getters should aim to return an error code whether the attribute could be retrieved.
Diffstat (limited to 'lib')
-rw-r--r--lib/route/tc.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/route/tc.c b/lib/route/tc.c
index 4b185ed..6b423a0 100644
--- a/lib/route/tc.c
+++ b/lib/route/tc.c
@@ -582,15 +582,17 @@ void rtnl_tc_set_chain(struct rtnl_tc *tc, uint32_t chain)
/**
* Return chain index of traffic control object
* @arg tc traffic control object
+ * @arg out_value output argument.
*
- * @return chain index of traffic control object or 0 if not set.
+ * @return 0 of the output value was successfully returned, or a negative
+ * error code on failure.
*/
-uint32_t rtnl_tc_get_chain(struct rtnl_tc *tc)
+int rtnl_tc_get_chain(struct rtnl_tc *tc, uint32_t *out_value)
{
- if (tc->ce_mask & TCA_ATTR_CHAIN)
- return tc->tc_chain;
- else
- return 0;
+ if (!(tc->ce_mask & TCA_ATTR_CHAIN))
+ return -NLE_MISSING_ATTR;
+ *out_value = tc->tc_chain;
+ return 0;
}
/** @} */