Re: [RFC] Documentation/CodingStyle: Add rules for goto labels

Rene Herman
2007-06-05T09:20:07Z

On 06/05/2007 04:10 AM, WANG Cong wrote:

> On Mon, Jun 04, 2007 at 01:57:51PM -0400, Jeff Garzik wrote:

>> A matter of opinion :) I tend to think goto is special enough to
>> warrant column 1 unconditionally. It is special, so it draws additional
>> attention over and above case labels.
>>
>> I and others have been tripped up when programmers "hide" goto
>> statements among regular statements.
>>
>> IMO goto warrants a big flashing "notice me" sign.

> Hmmm, perhaps.
>
> So, it seems that we can reach an agreement. Any other comments or
> suggestions?

One more -- I absolutely agree with Jeff that goto should stand out as best as
possible but I think that's actually more so when they're indented 2 columns.

Have been working on a legacy CD-ROM driver lately and puting "out:" labels at 2
spaces started out as a personal style preference of Pekka Enberg (I used to put
them at 0) but has grown on me. It makes them clearly fall inside the function,
not being aligned at the same level as the next function header, which makes
for the "lowest effort visual scan" of all I feel. One is just too little for
that, more than 2 is too much...

Here's the last version that was posted:

http://lkml.org/lkml/2007/6/4/50

It gets a little different visually when labels are mostly longer than a simple
"out" or "again", or "error" or something like that but if someone's going to
try to pin down the label style, I'd like the freedom to have two spaces in
front of them...

Rene.

P.S: Your message had a Mail-Followup-To set which dropped yourself and turned
the others from CCs into TOs. If you can help it, please no header tricks.