TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

OpenBSD kernel source file style guide

112 pointsby zytekover 10 years ago

9 comments

bjackmanover 10 years ago
I&#x27;ve never written code with it, but the BSDs use these macros to implement rudimentary generic types in C: <a href="http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/LIST_EMPTY.3?query=queue&amp;sec=3&amp;arch=i386" rel="nofollow">http:&#x2F;&#x2F;www.openbsd.org&#x2F;cgi-bin&#x2F;man.cgi&#x2F;OpenBSD-current&#x2F;man3&#x2F;...</a>. Nice.<p>However, I&#x27;ve only had horrible experiences trying to read the BSDs&#x27; kernel code. There are way too many statements like &quot;mst_fqd-&gt;f_do_skb((struct mfq_t *) q);&quot;
评论 #8665169 未加载
feldover 10 years ago
Linux&#x27;s is very long in comparison to the BSD&#x27;s. It seems to have weird edge-cases and possibly unnecessary explanations.<p><a href="https://www.kernel.org/doc/Documentation/CodingStyle" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;Documentation&#x2F;CodingStyle</a><p>Example: Why is the comment style different in net&#x2F;? It seems to serve no obvious purpose.<p>Too many cooks :-)
评论 #8663881 未加载
kpsover 10 years ago
The first published BSD KNF can be found various places including here: <a href="https://stuff.mit.edu/afs/athena/astaff/reference/4.4lite/usr/src/admin/style/style" rel="nofollow">https:&#x2F;&#x2F;stuff.mit.edu&#x2F;afs&#x2F;athena&#x2F;astaff&#x2F;reference&#x2F;4.4lite&#x2F;us...</a><p>Like the Linux kernel style, this is essentially K&amp;R style, and the style most of Unix was written in.
gcb0over 10 years ago
openbsd is the only project which manpages are not mostly useless. You have even a starting guide there.
评论 #8665444 未加载
评论 #8665173 未加载
ja30278over 10 years ago
I never understand the desire to omit braces in single line blocks.<p>sure<p><pre><code> for () foo </code></pre> saves you a line, but it&#x27;s a bug waiting to happen.
评论 #8664376 未加载
评论 #8665364 未加载
评论 #8665098 未加载
评论 #8664572 未加载
mheilerover 10 years ago
I like that it&#x27;s short.
bigfootover 10 years ago
Archaic and impractical. Example: Instead of using Linux&#x27; pragmatic approach to function prototypes:<p>&quot;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.&quot;<p>OpenBSD enforces this:<p>&quot;Prototypes should not have variable names associated with the types; i.e., void function(int); not: void function(int a);&quot;<p>Instead of letting the code tell the parameters&#x27; purposes, this now has to be deduced from informal descriptions, or the function definition in some .c file.
评论 #8664001 未加载
评论 #8663343 未加载
JelteFover 10 years ago
This is the first time I&#x27;ve heard of a style guide that demands a mixture of tabs and spaces. I thought this was very much frowned upon.
评论 #8664698 未加载
fredmorcosover 10 years ago
Here&#x27;s a question, since the man page mentions splint. Has anyone here ever managed to reach a splint warning-free project?