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

Patrick McHardy
2014-03-26T23:13:42Z

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