Xorg coding style (Was: Re: Radeon TV-in support in Xorg CVS.)

Vladimir Dergachev volodya at mindspring.com
Sun Oct 3 09:52:29 PDT 2004

> The following functions have no or partial indentation:
> fi1236.c:
> MT2032_dump_parameters, MT2032_getid, MT2032_shutdown, MT2032_init,
> MT2032_no_spur_in_band, MT2032_calculate_register_settings,
> MT2032_wait_for_lock, MT2032_implement_settings, MT2032_optimize_VCO,
> FI1236_get_afc_hint, MT2032_get_afc_hint, TUNER_get_afc_hint,
> MT2032_dump_status, MT2032_tune, FI1236_set_tuner_type,
> fi1236_dump_status

Many of these functions do not have any identation levels to speak of.
E.g. MT2032_dump_parameters, MT2032_shutdown.

> I noticed it using vi and less. I suspect your editor is doing some
> automagic to hide the ugliness from you. (I checked with hexdump - there
> are no '\t's, it's strictly "one line\nthe next line")

I guess we have a different preference for identation styles, I hope you 
won't think mine is as ugly as it seems once I explain why I use it.

It is based on linux kernel style, with the changes made to minimize 
keypresses required.

    * Each level of identation is exactly one tab more than previous one.
      This is useful because my editor (like many others) automatically
      goes to previous indentation level on ENTER.

    * No identation level for function bodies - there is nothing to
      confuse a function body with.

    * The blocks { /* body */ } are interchangeable with single statements:

 		else op2;

 		} else {

    * tabs are 8 spaces - it is easier to see this way and it
      works great with numbers.

I do recognize that other people prefer other styles. And (as can be seen 
from other code) I did try to comply with XFree86 style.

However, XFree86 style is a pain (literally - I don't think I have any 
stress disorder, but if type for long my fingers hurt a little) for me to 
use, so I try to format it like this only when a code is not likely to change.

If anyone knows any magic (based on indent or another program) that I can 
simply run on the files when I am done, I'll be very thankful.

My thoughts so far were to separate out MT2032 in different file and then 
the formatting will be consistent again. I vaguely remember someone saying 
that having a consistent style within one file is fine.


                                Vladimir Dergachev

> Most of the files I'm familiar with(*) in xorg, uses spaces for
> indentation, but some also use tabs - could we please have an official
> stance on this? Personally I prefer real spaces, but a strict policy
> either way is infinitely better than the current mix. I understand the
> reluctance to run the whole code base through indent or similar tools,
> but could we at least state some policy for new code?
> (*) Admittedly not all that many.
> -- 
> Ronny V. Vindenes <s864 at ii.uib.no>

More information about the xorg mailing list