However, I've only had horrible experiences trying to read the BSDs' kernel code. There are way too many statements like "mst_fqd->f_do_skb((struct mfq_t *) q);"
Yes! That's a really good implementations of linked lists using only preprocessor macros.
sys/queue.h is also provided in all Linux systems.
Easy to use, type-checked by the compiler and a lot faster than a "generic" linked list with pointers to the data.
Here, the next/previous pointers get embedded in the payload struct itself.
Likely because /net was done before the coding standard and by some 3rd party contributor -- and doing non-functional whitespace/formatting commits is a no-no in most large projects.
Agreed, this is the very reason I created a small script [1] to install them on non-OpenBSD systems. They are excellent for as references when coding C and to check what is most likely a GNU extension when writing portable shell scripts.
Are there not examples where a statement is pretty much guaranteed to live on its own within a block? Having said that, my own style is to always include braces, for aesthetic reasons if nothing else.
People keep saying that, but do bugs like that really happen? In my entire career as a professional software developer I've never seen it happening. Not once.
Archaic and impractical. Example: Instead of using Linux' pragmatic approach to function prototypes:
"In function prototypes, include parameter names with their data types.
Although this is not required by the C language, it is preferred in Linux
because it is a simple way to add valuable information for the reader."
OpenBSD enforces this:
"Prototypes should not have variable names associated with the types; i.e.,
void function(int);
not:
void function(int a);"
Instead of letting the code tell the parameters' purposes, this now has to be deduced from informal descriptions, or the function definition in some .c file.
I love how frequently people on HN decry actual real working things people actually work on and use as "impractical". I suspect the combined experience of the entire openbsd team is greater than yours.
[+] [-] bjackman|11 years ago|reply
However, I've only had horrible experiences trying to read the BSDs' kernel code. There are way too many statements like "mst_fqd->f_do_skb((struct mfq_t *) q);"
[+] [-] jpfr|11 years ago|reply
sys/queue.h is also provided in all Linux systems.
Easy to use, type-checked by the compiler and a lot faster than a "generic" linked list with pointers to the data. Here, the next/previous pointers get embedded in the payload struct itself.
[+] [-] feld|11 years ago|reply
https://www.kernel.org/doc/Documentation/CodingStyle
Example: Why is the comment style different in net/? It seems to serve no obvious purpose.
Too many cooks :-)
[+] [-] Alupis|11 years ago|reply
[+] [-] kps|11 years ago|reply
Like the Linux kernel style, this is essentially K&R style, and the style most of Unix was written in.
[+] [-] gcb0|11 years ago|reply
[+] [-] dredmorbius|11 years ago|reply
On the Linux side, Debian tends to support manpages better than others (they're required by Policy, though they're not release-critical).
[+] [-] ninjin|11 years ago|reply
[1]: https://github.com/ninjin/ppod/tree/master/hck/openbsd_manpa...
[+] [-] ja30278|11 years ago|reply
sure
saves you a line, but it's a bug waiting to happen.[+] [-] oneeyedpigeon|11 years ago|reply
[+] [-] ams6110|11 years ago|reply
[+] [-] lmm|11 years ago|reply
[+] [-] DrJokepu|11 years ago|reply
[+] [-] mheiler|11 years ago|reply
[+] [-] unknown|11 years ago|reply
[deleted]
[+] [-] bigfoot|11 years ago|reply
"In function prototypes, include parameter names with their data types. Although this is not required by the C language, it is preferred in Linux because it is a simple way to add valuable information for the reader."
OpenBSD enforces this:
"Prototypes should not have variable names associated with the types; i.e., void function(int); not: void function(int a);"
Instead of letting the code tell the parameters' purposes, this now has to be deduced from informal descriptions, or the function definition in some .c file.
[+] [-] imanaccount247|11 years ago|reply
[+] [-] 0x0|11 years ago|reply
[+] [-] JelteF|11 years ago|reply
[+] [-] Negitivefrags|11 years ago|reply
[+] [-] fredmorcos|11 years ago|reply
[+] [-] bjackman|11 years ago|reply
[deleted]