Home | Download | History | CodingStyle

 

THE OSIRIS PROJECT
##################

*Coding Style - How we like it in the sources*

The Osiris is implemented in the C language - like all other system level code with assembly code in the inevitable places. C being C and K&R being the authority in C we follow the logical coding style - K&R. Assembly routines would most preferably be in AT&T syntax for 'as' to let 'gcc' do all the work.

Indentations:

Tabs and hence indents *are* 8. Any other brain dead value like 4 or 2 is definitely not encouraged. It helps to find out screwy logic and blocks easily.

Variable names:

These ought to convey their use in a concise manner as possible. Hungarian syntax is strictly frowned upon and *will* result in the code being thrown out the window. Long novelletes for counters,etc. like "thiskeepscountofloops" and we'll give you a free I.Q. test. Function names can be descriptive like 'cache_alloc()' and so are global and static variables. Functions for system calls must have 'sys_' prefix to their names.

Program Blocks:

These are loop constructs and if-else. The braces for blocks *must* be on the same line as the starting conditionals of these constructs. We know there are other fancy places for putting braces, but the need is recognizable code...we are not on a mission to get a monkey to key in Hamlet in a 1000 years.

/*This is how*/

while(cond){
     /*code from here after an indent*/
}

if(cond){
    /*code*/
}else{
    /*code*/
    if(cnd){/*nested if-else*/
         /*code*/
    }
}

do{
    /*code*/
}while(cond); /*notice that while is on same line as the brace*/

Functions:

Functions should be preceded by a comment describing briefly their use and the method if complex. Function name should be on a line of its own including return types and params. If you have a param list of more than six you possibly must re-examine or its just one of those rare occurences. The braces for functions start on the next line on the first column...

/*Comments here
*
*/
int right_way(int x,int y)
{
    ...
}

Source Files:

The files must begin with the year and author of the file. This must be followed by a description of what is being handled in the file, this helps in grepping to locate specific info from sources. Any modifications to the file must contain the year and name of the person along with the specific details of what was done following the description mentioned above.

Comments:

Comments are a must in the sources, but not to the level of explaining why an 'else' block is entered if the 'if' condition is not true. Ignoring commenting will taken as an offence. We don't want to be too smart and dig our own holes do we.

The Osi-Maintainers.