Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:manual:contrib:coding_style_guidelines [2020/03/10 23:28]
emulatorman
en:manual:contrib:coding_style_guidelines [2022/03/28 17:27] (current)
i3_relativism ↷ Page moved from en:contrib:coding_style_guidelines to en:manual:contrib:coding_style_guidelines
Line 1: Line 1:
-====== HyperbolaBSD™ Coding Style Guidelines ======+====== HyperbolaBSD Coding Style Guidelines ======
  
 ===== Description ===== ===== Description =====
  
-This article specifies the preferred style for kernel source files in the <color #0BB928/#DDFFE3>HyperbolaBSD</color> source tree.  It is also a guide for preferred userland code style.+This article specifies the preferred style for kernel source files in the <color #0BB928/#DDFFE3>HyperbolaBSD</color> source tree.  It is also a guide for preferred userland code style.
 These guidelines should be followed for all new code.  In general, code can be considered “new code” when it makes up about 50% or more of the file(s) involved.  This is enough to break precedents in the existing code and use the current style guidelines. These guidelines should be followed for all new code.  In general, code can be considered “new code” when it makes up about 50% or more of the file(s) involved.  This is enough to break precedents in the existing code and use the current style guidelines.
  
 <code c> <code c>
 /* /*
- * Style guide for the HyperbolaBSD™ KNF (Kernel Normal Form).+ * Style guide for the HyperbolaBSD KNF (Kernel Normal Form).
  */  */
  
Line 108: Line 108:
 When declaring variables in structures, declare them sorted by use, then by size (largest to smallest), then by alphabetical order.  The first category normally doesn't apply, but there are exceptions.  Each one gets its own line.  Put a tab after the first word, i.e., use ‘<color #620BB9/#EEDDFF>int^Ix;</color>’ and ‘<color #620BB9/#EEDDFF>struct^Ifoo *x;</color>’. When declaring variables in structures, declare them sorted by use, then by size (largest to smallest), then by alphabetical order.  The first category normally doesn't apply, but there are exceptions.  Each one gets its own line.  Put a tab after the first word, i.e., use ‘<color #620BB9/#EEDDFF>int^Ix;</color>’ and ‘<color #620BB9/#EEDDFF>struct^Ifoo *x;</color>’.
  
-Major structures should be declared at the top of the file in which they are used, or in separate header files if they are used in multiple source files.  Use of the structures should be by separate declarations and should be “<color #620BB9/#EEDDFF>extern</color>” if they are declared in a header file.+Major structures should be declared at the top of the file in which they are used, or in separate header files if they are used in multiple source files.  Use of the structures should be separated by declarations and should be “<color #620BB9/#EEDDFF>extern</color>” if they are declared in a header file.
  
 <code c> <code c>
Line 123: Line 123:
 <code c> <code c>
 #include <sys/queue.h> #include <sys/queue.h>
-struct  foo {+struct foo {
         LIST_ENTRY(foo) link;   /* Queue macro glue for foo lists */         LIST_ENTRY(foo) link;   /* Queue macro glue for foo lists */
         struct  mumble amumble; /* Comment for mumble */         struct  mumble amumble; /* Comment for mumble */
Line 394: Line 394:
 ===== History ===== ===== History =====
  
-This article is largely based on the <color #0B71B9/#DDF1FF>src/admin/style/style</color> file from the <color #B90B0B/#FFDDDD>4.4BSD-Lite2</color> release, with updates to reflect the current practice and desire of the <color #0BB928/#DDFFE3>HyperbolaBSD</color> development.+This article is largely based on the <color #0B71B9/#DDF1FF>src/admin/style/style</color> file from the <color #B90B0B/#FFDDDD>4.4BSD-Lite2</color> release, with updates from the <color #B90B0B/#FFDDDD>OpenBSD</color> project to reflect the current practice and desire of the <color #0BB928/#DDFFE3>HyperbolaBSD</color> development.
  
 ===== Licensing ===== ===== Licensing =====
  
-This wiki article is released under the [[https://www.freebsd.org/copyright/freebsd-license.html|FreeBSD® License]].+This wiki article is released under the [[https://www.freebsd.org/copyright/freebsd-license.html|FreeBSD License]].
  
 ===== Acknowledgement ===== ===== Acknowledgement =====
  
-This wiki article is based on **[[https://man.openbsd.org/|OpenBSD® Manual Page]]**.+This wiki article is based on **4.4BSD-Lite2 Manual Page**.