static int
ValueOfNothing(afs_int32 nothing) {
- ...
- }
+ ...
+ }
Prototypes for functions which are shared within a module should go into the a header file named _module_ \_internal.h
- Use braces where it aids readability.
- Closing and opening braces go on the same line as the control statement
- if (foo) {
- ...
- } else {
- ...
- }
+ if (foo) {
+ ...
+ } else {
+ ...
+ }
- Code surrounded by brackets should have its continuation lines lined up with the relevant opening brace
- value = CostOfEverything(ValueOfNothing(0),
- fudge);
+ value = CostOfEverything(ValueOfNothing(0),
+ fudge);
- Loops with an empty body should have their trailing semicolon on the following line, to make the empty body explicit, and suppress a compiler warning
- for (...; ...; ...)
- ;
+ for (...; ...; ...)
+ ;
- Lines should be wrapped within 80 characters
- Always use size\_t for sizes of objects, not int or unsigned long, even if they're small objects. Exception: wire protocol objects should instead use types with explicit sizes, such as afs\_int32.
- Always use either size\_t or ptrdiff\_t for offsets into data structures or memory blocks, not int or long.
- All new APIs that take buffers should also take the length of the buffer as an additional parameter.
-- Where possible, move assignments outside of conditionals. In general, write code = function(); if (code = 0) not if ((code = function()) = 0).
+- Where possible, move assignments outside of conditionals. In general, write code = function(); if (code == 0) not if ((code = function()) == 0).
- Don't write new functions which take arrays as arguments
## <a name="Unix kernel module"></a> Unix kernel module
- All calls to obtain a write lock have a unique reference number. This must be unique across the cache manager (lock numbers that are in a particular OS directory may be shared, but only between OS directories), and src/afs/lock.h must be updated with the highest number in use
- New locks should be registered in the list in afs\_callback.c, so their contents can be viewed via cmdebug
--- [[SimonWilkinson]] - 27 Jul 2009
+-- Simon Wilkinson - 27 Jul 2009