1145510Sdarrenr 2145510SdarrenrOver time, I am moving all of the IPFilter code to what I consider a better 3145510Sdarrenrcoding style than it had before. If you submit patches, I expect them to 4145510Sdarrenrconform as appropriate. 5145510Sdarrenr 6145510SdarrenrFunction Comments 7145510Sdarrenr================= 8145510SdarrenrPreceeding each and every function, a comment block like this should 9145510Sdarrenrbe present: 10145510Sdarrenr 11145510Sdarrenr/* ------------------------------------------------------------------------ */ 12145510Sdarrenr/* Function: function-name */ 13145510Sdarrenr/* Returns: return-type */ 14145510Sdarrenr/* Parameters: param1(I) - param1 is an input parameter */ 15145510Sdarrenr/* p2(O) - p2 is an output parameter passed as an arg */ 16145510Sdarrenr/* par3(IO) - par3 is a parameter which is both input and */ 17145510Sdarrenr/* output. Pointers to things which are used and */ 18145510Sdarrenr/* then get a result stored in them qualify here. */ 19145510Sdarrenr/* */ 20145510Sdarrenr/* Description about what the function does. This comment should explain */ 21145510Sdarrenr/* any gotchas or algorithms that are used which aren't obvious to the */ 22145510Sdarrenr/* casual reader. It should not be an excuse to not use comments inside */ 23145510Sdarrenr/* the function. */ 24145510Sdarrenr/* ------------------------------------------------------------------------ */ 25145510Sdarrenr 26145510Sdarrenr 27145510SdarrenrTab spacing 28145510Sdarrenr=========== 29145510SdarrenrTabs are to be at 8 characters. 30145510Sdarrenr 31145510Sdarrenr 32145510SdarrenrConditions 33145510Sdarrenr========== 34145510SdarrenrAll expressions which evaluate to a boolean for a test condition, such as 35145510Sdarrenrin an if()/while() statement must involve a boolean operation. Since C 36145510Sdarrenrhas no native boolean type, this means that one of <,>,<=,>=,==,!= must 37145510Sdarrenrbe present. Implied boolean evaluations are out. 38145510Sdarrenr 39145510SdarrenrIn code, the following is banned: 40145510Sdarrenr 41145510Sdarrenrif (x) 42145510Sdarrenrif (!x) 43145510Sdarrenrwhile ((a = b)) 44145510Sdarrenr 45145510Sdarrenrand should be replaced by: 46145510Sdarrenr 47145510Sdarrenrif (x != 0) 48145510Sdarrenrif (x == 0) 49145510Sdarrenrwhile ((a = b) != 0) 50145510Sdarrenr 51145510SdarrenrIf pointers are involved, always compare with NULL, ie.: 52145510Sdarrenr 53145510Sdarrenrif (x != NULL) 54145510Sdarrenrif (x == NULL) 55145510Sdarrenrwhile ((a = b) != NULL) 56145510Sdarrenr 57145510Sdarrenr 58