Re: do { ... } while (0) addition.

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

 



On Wed, Sep 24, 2003 at 13:22:47 -0700, Corey Brenner wrote:
> There is another reason for do { ... } while (0).
> 
> That is, it allows you to break out of the block
> early if some condition is met, without defining
> a label and using goto.  Consider:
> 
> do {
> 	if (foo)
> 		break;
> 
> 	some();
> 	thing();
> 	which();
> 	takes();
> 	forever();
> } while (0);

A goto is actualy more readable once you get more than two levels of
indentation involved. Because to see where a break goes, you have to
inspect what is before *opening* brace to see on which *closing* brace
it will jump. While with goto you just search for the label, which is
usualy in the first column.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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