Jesper Juhl <[EMAIL PROTECTED]> wrote: > On 7/11/05, Michael S. Tsirkin <[EMAIL PROTECTED]> wrote:
> [snip] > > 3e. sizeof > > space after the operator > > sizeof a > I don't think that's a hard rule, there's plenty of code that does > "sizeof(type)" and not "sizeof (type)", and whitespace cleanup > patches I've done that change "sizeof (type)" into "sizeof(type)" have > generally been accepted. It is necessary /not/ to put space between "function name" and '(', because if it is a function-like macro, it does matter. For uniformity, do it for functions and operations like sizeof too. > [snip] > > > > 4. Indentation rules for C > > Use tabs, not spaces, for indentation. Tabs should be 8 characters > > wide. > A tab is a tab is a tab, how it's displayed is up to the editor > showing the file. But editing a file with tab==4 and editing it later with tab==8 guarantees a mess. [...] > > 6. One-line statement does not need a {} block, so dont put it into one > > if (foo) > > bar; > Not always so, if `bar' is a macro adding {} may be safer. Such macros are /very/ dangerous. That's one reason why multi-line macros must be wrapped in "do { ... } while(0)" > Also > sometimes adding {} improves readability, which is important. Or leaves an old C hand wondering what is going on... > > 7. Comments > > Dont use C99 // comments. > > > > s/Dont/Don't/ > > > > 9a. Integer types > > int is the default integer type. > > Use unsigned type if you perform bit operations (<<,>>,&,|,~). > > Use unsigned long if you have to fit a pointer into integer. > > long long is at least 64 bit wide on all platforms. > > char is for ASCII characters and strings. > > Use u8,u16,u32,u64 if you need an integer of a specific size. > > u8,s8,u16,s16,u32,s32,u64,s64 Plus annotations for bitwise and such. See Documentation/sparse.txt -- Dr. Horst H. von Brand User #22616 counter.li.org Departamento de Informatica Fono: +56 32 654431 Universidad Tecnica Federico Santa Maria +56 32 654239 Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/