TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

OpenBSD kernel source file style guide

112 点作者 zytek超过 10 年前

9 条评论

bjackman超过 10 年前
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 未加载
feld超过 10 年前
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 未加载
kps超过 10 年前
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.
gcb0超过 10 年前
openbsd is the only project which manpages are not mostly useless. You have even a starting guide there.
评论 #8665444 未加载
评论 #8665173 未加载
ja30278超过 10 年前
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 未加载
mheiler超过 10 年前
I like that it&#x27;s short.
bigfoot超过 10 年前
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 未加载
JelteF超过 10 年前
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 未加载
fredmorcos超过 10 年前
Here&#x27;s a question, since the man page mentions splint. Has anyone here ever managed to reach a splint warning-free project?