Re: [patch] drivers: phy: tweaks to phy_create()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 06, 2013 at 01:41:26PM +0530, Kishon Vijay Abraham I wrote:

> >The rest of this patch is just cleanup like returning directly instead
> >of having do-nothing gotos.  Using descriptive labels instead of
> 
> Grouping the err returns in the end looked a bit cleaner to me. It's
> just a matter of preference I guess.

Say if you are reading the code and it says:

	goto err0;

What you think is, "Huh, that's a crap name for a label.  I wonder what
it does?"  So you have interrupt what you are doing and scroll down and
then you see that it doesn't do anything.  Not a single thing.  It just
returns.  Then you have to scroll back and try remember where you were.

But if you use a clear label like:

	ret = -ENOMEM;
	goto return_ret;

Then I don't have to scroll down to find out what it is.

But it's even more clear to just say:

	return -ENOMEM;

The original code was not just messy, it was also buggy.  If you do the
error handling in the right way by unwinding in the correct order and
thinking about label names then your code will be less buggy.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux