netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* is assert() an appropriate substitute for return -1?
@ 2011-03-24 18:23 Sam Roberts
  2011-03-28 12:51 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Roberts @ 2011-03-24 18:23 UTC (permalink / raw)
  To: Netfilter Developer Mailing List

>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?

Cheers,
Sam

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-28 15:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24 18:23 is assert() an appropriate substitute for return -1? Sam Roberts
2011-03-28 12:51 ` Pablo Neira Ayuso
2011-03-28 15:47   ` Sam Roberts

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).