From cbded627a15baf792465c0cbe960b36cb9408fe2 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 7 May 2010 11:26:41 +0200 Subject: change errno values for mnl_cb_run[2]() This patch changes the errno value of mnl_cb_run[2]() in the following two cases: * Invalid expected portID: ESRCH. * Invalid sequence number: EPROTO. I didn't find any better generic errno value. EINVAL is reserved for malformed messages, to avoid confusions. Signed-off-by: Pablo Neira Ayuso --- src/callback.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/callback.c b/src/callback.c index 4a73857..ded22aa 100644 --- a/src/callback.c +++ b/src/callback.c @@ -64,7 +64,10 @@ static mnl_cb_t default_cb_array[NLMSG_MIN_TYPE] = { * - MNL_CB_STOP (=0): stop callback runqueue. * - MNL_CB_OK (>=1): no problems has occurred. * - * This function propagates the callback return value. + * This function propagates the callback return value. On error, it returns + * -1 and errno is explicitly set. If the portID is not the expected, errno + * is set to ESRCH. If the sequence number is not the expected, errno is set + * to EPROTO. */ int mnl_cb_run2(const char *buf, size_t numbytes, unsigned int seq, unsigned int portid, mnl_cb_t cb_data, void *data, @@ -76,12 +79,12 @@ int mnl_cb_run2(const char *buf, size_t numbytes, unsigned int seq, while (mnl_nlmsg_ok(nlh, len)) { /* check message source */ if (!mnl_nlmsg_portid_ok(nlh, portid)) { - errno = EINVAL; + errno = ESRCH; return -1; } /* perform sequence tracking */ if (!mnl_nlmsg_seq_ok(nlh, seq)) { - errno = EILSEQ; + errno = EPROTO; return -1; } -- cgit v1.2.3