Skip to contentSkip to conversation

Coding style / indent options

DISCUSSION Colin D Bennett 2 participants 2 messages Apr 29, 2008 – May 1, 2008

lore
Share & tools
lore
#0 lore raw

Does anyone have a set of GNU indent (or astyle) options that correspond to the proper format for GRUB source code? I want to make sure I'm using the correct style so that I don't produce spurious changes when files I'm editing are reformatted.

I tried using GNU indent (with the default GNU style) on a few GRUB 2 source files to see what differences resulted, and I observed the following differences:

                                             GRUB  GNU 
                                             ====  ===
(1) Space after unary '!' operator           Yes   No 
(2) Space between macro name and open paren  No    Yes
(3) Max line length                          >=80  <80
(4) Space between __attribute__ and parens   No    Yes
(5) Keep indenting spaces on blank lines     Yes   No

I did notice, however, that in some places (e.g., normal/functions.c lines 84-87) the space/TAB usage is inconsistent). I assume that replacing 8 spaces with TAB characters is the desired usage (as GNU style suggests).

I just want to keep the code I modify and produce as clean and uniform as possible, and produce clean patches.

Thanks,
Colin

#1 lore raw
Quoted 16 lines · Colin D Bennett

Does anyone have a set of GNU indent (or astyle) options that correspond to the proper format for GRUB source code? I want to make sure I'm using the correct style so that I don't produce spurious changes when files I'm editing are reformatted.

I tried using GNU indent (with the default GNU style) on a few GRUB 2 source files to see what differences resulted, and I observed the following differences:

                                             GRUB  GNU 
                                             ====  ===
(1) Space after unary '!' operator           Yes   No (2) Space between macro name and open paren  No    Yes
(3) Max line length                          >=80  <80
(4) Space between __attribute__ and parens   No    Yes
(5) Keep indenting spaces on blank lines     Yes   No
Quoted 7 lines

I did notice, however, that in some places (e.g., normal/functions.c lines 84-87) the space/TAB usage is inconsistent). I assume that replacing 8 spaces with TAB characters is the desired usage (as GNU style suggests).

I just want to keep the code I modify and produce as clean and uniform as possible, and produce clean patches.

Hi Colin,

As you noted it is not too strict :).

So best bet is to follow what you see elsewhere in GRUB 2 code base and follow that. Of course one could argue should conventions be followed more closely.

Just make it look clean and try to follow most of the rules. We will spot them for you if we see the reason :)

It is usually a good idea to review contents of patches beforehand and try to keep changes as minimal as possible.

Thanks,
Vesa Jääskeläinen