Deleted Added
full compact
style.9 (103189) style.9 (106092)
1.\" Copyright (c) 1995-2001 FreeBSD Inc.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 29 unchanged lines hidden (view full) ---

38Be careful to check the examples before assuming that
39.Nm
40is silent on an issue.
41.Bd -literal
42/*
43 * Style guide for FreeBSD. Based on the CSRG's KNF (Kernel Normal Form).
44 *
45 * @(#)style 1.14 (Berkeley) 4/28/95
1.\" Copyright (c) 1995-2001 FreeBSD Inc.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 29 unchanged lines hidden (view full) ---

38Be careful to check the examples before assuming that
39.Nm
40is silent on an issue.
41.Bd -literal
42/*
43 * Style guide for FreeBSD. Based on the CSRG's KNF (Kernel Normal Form).
44 *
45 * @(#)style 1.14 (Berkeley) 4/28/95
46 * $FreeBSD: head/share/man/man9/style.9 103189 2002-09-10 14:48:38Z robert $
46 * $FreeBSD: head/share/man/man9/style.9 106092 2002-10-28 19:33:22Z rwatson $
47 */
48
49/*
50 * VERY important single-line comments look like this.
51 */
52
53/* Most single-line comments look like this. */
54

--- 22 unchanged lines hidden (view full) ---

77and to keep the IDs out of object files.
78Only add
79.Dq Li "From: "
80in front of foreign VCS IDs if the file is renamed.
81.Bd -literal
82#if 0
83#ifndef lint
84static char sccsid[] = "@(#)style 1.14 (Berkeley) 4/28/95";
47 */
48
49/*
50 * VERY important single-line comments look like this.
51 */
52
53/* Most single-line comments look like this. */
54

--- 22 unchanged lines hidden (view full) ---

77and to keep the IDs out of object files.
78Only add
79.Dq Li "From: "
80in front of foreign VCS IDs if the file is renamed.
81.Bd -literal
82#if 0
83#ifndef lint
84static char sccsid[] = "@(#)style 1.14 (Berkeley) 4/28/95";
85#endif /* not lint */
85#endif /* !lint */
86#endif
87
88#include <sys/cdefs.h>
86#endif
87
88#include <sys/cdefs.h>
89__FBSDID("$FreeBSD: head/share/man/man9/style.9 103189 2002-09-10 14:48:38Z robert $");
89__FBSDID("$FreeBSD: head/share/man/man9/style.9 106092 2002-10-28 19:33:22Z rwatson $");
90.Ed
91.Pp
92Leave another blank line before the header files.
93.Pp
94Kernel include files (i.e.\&
95.Pa sys/*.h )
96come first; normally, include
97.Aq Pa sys/types.h

--- 77 unchanged lines hidden (view full) ---

175for pretty-printers and editors.
176.Bd -literal
177#define MACRO(x, y) do { \e
178 variable = (x) + (y); \e
179 (y) += 2; \e
180} while (0)
181.Ed
182.Pp
90.Ed
91.Pp
92Leave another blank line before the header files.
93.Pp
94Kernel include files (i.e.\&
95.Pa sys/*.h )
96come first; normally, include
97.Aq Pa sys/types.h

--- 77 unchanged lines hidden (view full) ---

175for pretty-printers and editors.
176.Bd -literal
177#define MACRO(x, y) do { \e
178 variable = (x) + (y); \e
179 (y) += 2; \e
180} while (0)
181.Ed
182.Pp
183When code blocks are conditionally defined using
184.Ic #ifdef
185or
186.Ic #if ,
187a comment may be added following the matching
188.Ic #endif
189or
190.Ic #else
191to permit the reader to easily discern where conditionally defined code
192regions end.
193This comment should be used only for (subjectively) long regions, regions
194greater than 20 lines, or where a series of nested
195.Ic #ifdef 's
196may be confusing to the reader.
197Exceptions may be made for cases where code is contionally undefined for
198the purposes of lint, even though the undefined region may be small.
199The comment shall be seperated from the
200.Ic #endif
201or
202.Ic #else
203by a single space.
204For short conditionally defined regions, a closing comment should not be
205used.
206.Pp
207The comment for
208.Ic #endif
209should match the expression used in
210.Ic #if
211or
212.Ic #ifdef .
213The comment for
214.Ic #else
215should be the inverse of the expression used in the previous
216.Ic #if
217or
218.Ic #elsif .
219In the comments, the subexpression
220.Dq Li defined(FOO)
221is abbreviated as
222.Dq Li FOO .
223For the purposes of comments,
224.Dq Ic #ifndef Li FOO
225is treated as
226.Dq Ic #if Li !defined(FOO) .
227.Bd -literal
228#ifdef KTRACE
229#include <sys/ktrace.h>
230#endif
231
232#ifdef COMPAT_43
233/* A long block here, or other conditional code. */
234#else /* !COMPAT_43 */
235/* Or here. */
236#endif /* COMPAT_43 */
237
238#ifndef COMPAT_43
239/* Yet another long block here, or other conditional code. */
240#else /* COMPAT_43 */
241/* Or here. */
242#endif /* !COMPAT_43*/
243.Ed
244.Pp
183Enumeration values are all uppercase.
184.Bd -literal
185enum enumtype { ONE, TWO } et;
186.Ed
187.Pp
188In declarations, do not put any whitespace between asterisks and
189adjacent tokens, except for tokens that are identifiers related to
190types. (These identifiers are the names of basic types, type

--- 539 unchanged lines hidden ---
245Enumeration values are all uppercase.
246.Bd -literal
247enum enumtype { ONE, TWO } et;
248.Ed
249.Pp
250In declarations, do not put any whitespace between asterisks and
251adjacent tokens, except for tokens that are identifiers related to
252types. (These identifiers are the names of basic types, type

--- 539 unchanged lines hidden ---