Re: [PATCH] net/bonding: adjust codingstyle for bond_3ad files

Joe Perches
2011-05-10T02:11:38Z

On Mon, 2011-05-09 at 19:00 -0700, Jay Vosburgh wrote:
> {
> u32 bandwidth;
>
> if (aggregator->num_of_ports) {
> switch (...) {
> case AD_LINK_SPEED_WHATEVER:
> bandwidth = something;
> break;
> default:
> pr_warn or WARN(1, ...);
> bandwidth = 0;
> }
> return bandwidth;
> }
> return 0;
> }

My preference is to return early and reduce indentation.

It can make things like pr_<foo> or WARN more likely to
fit on a single.

{
int bandwidth;

if (!aggregator->num_of_ports)
return 0;

switch (...) {
case FOO:
bandwidth = bar;
break;
...
}

return bandwidth;
}