Re: [PATCH][v6] netlink: have netlink per-protocol bind function return an error code.

From: Patrick McHardy
Date: Wed Mar 26 2014 - 19:21:57 EST


On Tue, Mar 25, 2014 at 08:50:56AM -0400, Richard Guy Briggs wrote:
> + if (nlk->netlink_bind && nladdr->nl_groups) {
> + int i;
> +
> + for (i = 0; i < nlk->ngroups; i++)
> + if (test_bit(i, (long unsigned int *)&nladdr->nl_groups)) {
> + err = nlk->netlink_bind(i);
> + if (err) {
> + int undo;
> + if (!nlk->portid)
> + netlink_remove(sk);
> + for (undo = 0; undo < i; undo++)
> + if (nlk->netlink_unbind)
> + nlk->netlink_unbind(undo);

Do we really need 7 levels of indentation? You could save at least
one by using

if (!test_bit(...)
continue;
...

Or maybe simply move this to a helper function.



> + return err;
> + }
> + }
> + }
> +
> netlink_table_grab();
> netlink_update_subscriptions(sk, nlk->subscriptions +
> hweight32(nladdr->nl_groups) -
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/