Re: Goto statements in the Kernel

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

 



On Sun, Aug 07, 2005 at 15:13:18 +0200, Bob Smith wrote:
> Hi,
> 
> There are numerous places in the Linux Kernel where the
> C_Programming_Books_Most_Dreaded statement ('goto' of course)
> is used.

Most C programming books are wrong in this point ;-). Goto is part of the
language because it is useful at times and occasionaly even necessary.
The generic rule for readability is, that a construct that best represents
what's going on should be used.

Goto is legitimate for handling errors, roughly where languages equipped with
exceptions would throw one of those. They keep the boring error-handling
stuff out of the interesting line of useful things the function really does.

By the way, most of the time you could rewrite those gotos to ifs _without_
introducing repetition, but it would still introduce many levels of
indentation, that would make the code unreadable.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux