[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gotos
Muli Ben-Yehuda <mulix@mulix.org> writes:
> On Thu, Jan 08, 2004 at 02:30:06PM +0100, Tim Cambrant wrote:
>> Could someone please explain to me why we have a bunch
>> of gotos where they really could be removed? I'm sure
>> there is a good reason, but I simply don't see it. For
>> example, why shouldn't the following patch be applied?
>> I'd appreciate any explanation I could get. Thank you.
>
> In this case, I agree that the patch could be applied. However,
> there's a school of thought that goes something like this
>
> - we might add locking or some other resource acquisition to this
> function in the future
> - when we do, it would have to be converted to this 'goto style' to
> clean up properly
> - therefore, just use the goto style from the beginning, for
> consistency
>
> And I agree with that school of thought as well. It boils down to the
> style of whoever wrote the code.
For what it's worth, these kinds of needless gotos are often the
result of locking/cleanup code that's removed by a patch. The patch
author is probably just trying to make minimal changes to the kernel.
Recently that happened, and Linus asked the patch author to remove the
goto.
--
--Ed L Cashin | PGP public key:
ecashin@uga.edu | http://noserose.net/e/pgp/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/