/* *INDENT-OFF* */
/* *INDENT-ON* */
gridengine/source/scripts/format.sh
Inside Grid Engine we use line comments to describe certain attributes, block comments to explain bigger code sections and Autodoc comments (ADOC) to declare modules, functions and other important parts of the software.
Line comments look like this
lList ptf_job; /* JL_Type */They are at the end of a line after the code or in the line before it just like block comments as shown below:
/* * Stuff implementing fast access to the next job * that is to be dispatched accordingly to the * job sorting policy */ if (!so_pgr) { so_pgr = lParseSor ...ADOC comments can be extracted from the source code by the adoc tool. The adoc tool identifies the different sections inside an ADOC comment and creates a texinfo file which can be converted to man/html pages, pdf, GNU Info ...
/****** src/sge_ls_get_pid() ********************************* * * NAME * sge_ls_get_pid -- get pid of a loadsensor * * SYNOPSIS * static pid_t sge_ls_get_pid(lListElem *this_ls) * * FUNCTION * Returns the pid which is stored in a CULL element of * the type LS_Type. If the corresponding loadsensor was * not started until now then -1 will be returned. * * INPUTS * this_ls - pointer to a CULL element of type LS_Type * * RESULT * returns pid or -1 * *************************************************************/This is a typical ADOC-comment describing a function. Source code inside ADOC comments should look like the real source code. Information about using ADOC can be found here
TODOOptionally an IssueZilla id can be specified referencing the correspondent issue.
DEBUG
static int qmod_queue_weakclean(lListElem *qep, u_long32 force, lList **answer, char *user, char *host, int isoperator, int isowner) { ... }They should start with the qualifier and return type. There is no space between the function name and the open parentheses. If the arguments do not fit into one line split the line and continue the arguments under the first one of the previous line. The brace in function definitions, has to be in column zero again. Statements inside the function body should be indented with 3 spaces like Statements inside a compound statement. In contrast to functions, the opening left brace of a compound statement should be at the end of the line beginning the compound statement and the closing right brace should be alone on a line. Some examples:
for (i = 0; i < MAX; i++) { ... } while (1) { ... } do { ... } while (!found); if (i == 1) { ... } else if (i == -5) { ... } else { only_one_call(); } switch (i) { case 1,2: ... break; case 3: ... break; default: ... } struct name { char *first; }
There is one space between the keyword and the open parentheses.
Braces are in the same line like the keywords. They should be used even
if it is not necessary. Function calls do not contain spaces between the
function name and the open parentheses.
static void sge_set_ls_fds(lListElem *this_ls, fd_set *fds) { int i, k, l; int j = -1; int name[3] = { LS_out, LS_in, LS_err }; FILE *file; ...
Try to avoid nested expressions where multiple assignments or the ?-operators are envolved.
Use #if 0 to disable code sections and add a short comment why this code was disabled.