From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Sam Roberts <vieuxtech@gmail.com>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: is assert() an appropriate substitute for return -1?
Date: Mon, 28 Mar 2011 14:51:15 +0200 [thread overview]
Message-ID: <4D908443.6070703@netfilter.org> (raw)
In-Reply-To: <AANLkTikDX+SqxROiZDQZXop_Ooiv9QXZR3JJ66sG2m--@mail.gmail.com>
On 24/03/11 19:23, Sam Roberts wrote:
> From libnfnetlink.c:
>
>
> * On success, 0 is returned. On error, -1 is returned and errno is set
> * appropiately.
> */
> int nfnl_callback_register(struct nfnl_subsys_handle *ssh,
> u_int8_t type, struct nfnl_callback *cb)
> {
> assert(ssh);
> assert(cb);
>
> if (type>= ssh->cb_count) {
> errno = EINVAL;
> return -1;
> }
>
> The docs say return -1, the code asserts on two arg checks, and
> returns an error for the third.
>
> I found this behaviour when calling nfct_callback_register() on a
> handle that was opened with the EXPECT subsystem.
>
> It appears to be the prevalent convention in the code, but I'm binding
> the nfct APIs into lua, and would like users of the scripting language
> to not have abort()ions on misuse of the API.
>
> I'm not super-keen on checking in my binding code all the conditions
> in underlying asserts. And there is no public nfct API to determine
> what subsystem the handle was opened on, anyhow, so I can't easily
> check.
>
> Is it worth supplying patches?
I read once in the manpages that you can disable assert() macro with NDEBUG.
Is that enough for you?
next prev parent reply other threads:[~2011-03-28 12:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 18:23 is assert() an appropriate substitute for return -1? Sam Roberts
2011-03-28 12:51 ` Pablo Neira Ayuso [this message]
2011-03-28 15:47 ` Sam Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D908443.6070703@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=vieuxtech@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).