xref: /freebsd/share/man/man9/style.9 (revision c6e475ff5ab177d1bfa2fe8eaf9678fd165649fa)
1.\"-
2.\" Copyright (c) 1995-2005 The FreeBSD Project
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL [your name] OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\"	From: @(#)style	1.14 (Berkeley) 4/28/95
27.\" $FreeBSD$
28.\"
29.Dd June 3, 2019
30.Dt STYLE 9
31.Os
32.Sh NAME
33.Nm style
34.Nd "kernel source file style guide"
35.Sh DESCRIPTION
36This file specifies the preferred style for kernel source files in the
37.Fx
38source tree.
39It is also a guide for the preferred userland code style.
40Many of the style rules are implicit in the examples.
41Be careful to check the examples before assuming that
42.Nm
43is silent on an issue.
44.Bd -literal
45/*
46 * Style guide for FreeBSD.  Based on the CSRG's KNF (Kernel Normal Form).
47 *
48 *	@(#)style	1.14 (Berkeley) 4/28/95
49 * $FreeBSD$
50 */
51
52/*
53 * VERY important single-line comments look like this.
54 */
55
56/* Most single-line comments look like this. */
57
58/*
59 * Multi-line comments look like this.  Make them real sentences.  Fill
60 * them so they look like real paragraphs.
61 */
62.Ed
63.Pp
64The copyright header should be a multi-line comment, with the first
65line of the comment having a dash after the star like so:
66.Bd -literal
67/*-
68 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
69 *
70 * Copyright (c) 1984-2025 John Q. Public
71 *
72 * Long, boring license goes here, but trimmed for brevity
73 */
74.Ed
75.Pp
76An automatic script collects license information from the tree for
77all comments that start in the first column with
78.Dq Li "/*-" .
79If you desire to flag
80.Xr indent 1
81to not reformat a comment that starts in the first column which is not a
82license or copyright notice, change the dash to a star for those
83comments.
84Comments starting in columns other than the first are never
85considered license statements.
86Use the appropriate SPDX-License-Identifier line before the copyright.
87.Pp
88After any copyright header, there is a blank line, and the
89.Li $\&FreeBSD$
90for non C/C++ language source files.
91Version control system ID tags should only exist once in a file
92(unlike in this one).
93Non-C/C++ source files follow the example above, while C/C++ source files
94follow the one below.
95All VCS (version control system) revision identification in files obtained
96from elsewhere should be maintained, including, where applicable, multiple IDs
97showing a file's history.
98In general, do not edit foreign IDs or their infrastructure.
99Unless otherwise wrapped (such as
100.Dq Li "#if defined(LIBC_SCCS)" ) ,
101enclose both in
102.Dq Li "#if 0 ... #endif"
103to hide any uncompilable bits
104and to keep the IDs out of object files.
105Only add
106.Dq Li "From: "
107in front of foreign VCS IDs if the file is renamed.
108.Bd -literal
109/* From: @(#)style	1.14 (Berkeley) 4/28/95 */
110
111#include <sys/cdefs.h>
112__FBSDID("$FreeBSD$");
113.Ed
114.Pp
115Leave one blank line before the header files.
116.Pp
117Kernel include files
118.Pa ( sys/*.h )
119come first.
120If
121.In sys/cdefs.h
122is needed for
123.Fn __FBSDID ,
124include it first.
125If either
126.In sys/types.h
127or
128.In sys/param.h
129is needed, include it before other include files.
130.Po
131.In sys/param.h
132includes
133.In sys/types.h ;
134do not include both.
135.Pc
136The remaining kernel headers should be sorted alphabetically.
137.Bd -literal
138#include <sys/types.h>	/* Non-local includes in angle brackets. */
139#include <sys/endian.h>
140#include <sys/lock.h>
141#include <sys/queue.h>
142.Ed
143.Pp
144For a network program, put the network include files next.
145.Bd -literal
146#include <net/if.h>
147#include <net/if_dl.h>
148#include <net/route.h>
149#include <netinet/in.h>
150#include <protocols/rwhod.h>
151.Ed
152.Pp
153Do not include files from
154.Pa /usr/include
155in the kernel.
156.Pp
157Leave a blank line before the next group, the
158.Pa /usr/include
159files,
160which should be sorted alphabetically by name.
161.Bd -literal
162#include <stdio.h>
163.Ed
164.Pp
165Global pathnames are defined in
166.In paths.h .
167Pathnames local
168to the program go in
169.Qq Pa pathnames.h
170in the local directory.
171.Bd -literal
172#include <paths.h>
173.Ed
174.Pp
175Leave another blank line before the local include files.
176.Bd -literal
177#include "pathnames.h"		/* Local includes in double quotes. */
178.Ed
179.Pp
180Do not
181.Ic #define
182or declare names in the implementation namespace except
183for implementing application interfaces.
184.Pp
185The names of
186.Dq unsafe
187macros (ones that have side effects), and the names of macros for
188manifest constants, are all in uppercase.
189The expansions of expression-like macros are either a single token
190or have outer parentheses.
191Put a single tab character between the
192.Ic #define
193and the macro name.
194If a macro is an inline expansion of a function, the function name is
195all in lowercase and the macro has the same name all in uppercase.
196.\" XXX the above conflicts with ANSI style where the names are the
197.\" same and you #undef the macro (if any) to get the function.
198.\" It is not followed for MALLOC(), and not very common if inline
199.\" functions are used.
200Right-justify the
201backslashes; it makes it easier to read.
202If the macro encapsulates a compound statement, enclose it in a
203.Ic do
204loop,
205so that it can safely be used in
206.Ic if
207statements.
208Any final statement-terminating semicolon should be
209supplied by the macro invocation rather than the macro, to make parsing easier
210for pretty-printers and editors.
211.Bd -literal
212#define	MACRO(x, y) do {						\e
213	variable = (x) + (y);						\e
214	(y) += 2;							\e
215} while (0)
216.Ed
217.Pp
218When code is conditionally compiled using
219.Ic #ifdef
220or
221.Ic #if ,
222a comment may be added following the matching
223.Ic #endif
224or
225.Ic #else
226to permit the reader to easily discern where conditionally compiled code
227regions end.
228This comment should be used only for (subjectively) long regions, regions
229greater than 20 lines, or where a series of nested
230.Ic #ifdef 's
231may be confusing to the reader.
232The comment should be separated from the
233.Ic #endif
234or
235.Ic #else
236by a single space.
237For short conditionally compiled regions, a closing comment should not be
238used.
239.Pp
240The comment for
241.Ic #endif
242should match the expression used in the corresponding
243.Ic #if
244or
245.Ic #ifdef .
246The comment for
247.Ic #else
248and
249.Ic #elif
250should match the inverse of the expression(s) used in the preceding
251.Ic #if
252and/or
253.Ic #elif
254statements.
255In the comments, the subexpression
256.Dq Li defined(FOO)
257is abbreviated as
258.Dq Li FOO .
259For the purposes of comments,
260.Dq Ic #ifndef Li FOO
261is treated as
262.Dq Ic #if Li !defined(FOO) .
263.Bd -literal
264#ifdef KTRACE
265#include <sys/ktrace.h>
266#endif
267
268#ifdef COMPAT_43
269/* A large region here, or other conditional code. */
270#else /* !COMPAT_43 */
271/* Or here. */
272#endif /* COMPAT_43 */
273
274#ifndef COMPAT_43
275/* Yet another large region here, or other conditional code. */
276#else /* COMPAT_43 */
277/* Or here. */
278#endif /* !COMPAT_43 */
279.Ed
280.Pp
281The project is slowly moving to use the
282.St -isoC-99
283unsigned integer identifiers of the form
284.Vt uintXX_t
285in preference to the older
286.Bx Ns -style
287integer identifiers of the form
288.Vt u_intXX_t .
289New code should use the former, and old code should be converted to
290the new form if other major work is being done in that area and
291there is no overriding reason to prefer the older
292.Bx Ns -style .
293Like white-space commits, care should be taken in making
294.Vt uintXX_t
295only commits.
296.Pp
297Similarly, the project is slowly moving to use the
298.St -isoC-99
299.Vt bool
300in preference to the older
301.Vt int
302or
303.Vt boolean_t .
304New code should use
305.Vt bool ,
306and old code may be converted if it is
307reasonable to do so.
308Literal values are named
309.Dv true
310and
311.Dv false .
312These are preferred to the old spellings
313.Dv TRUE
314and
315.Dv FALSE .
316Userspace code should include
317.In stdbool.h ,
318while kernel code should include
319.In sys/types.h .
320.Pp
321Likewise, the project is moving to using the
322.St -isoC-99
323designated initializers when it makes sense to do so.
324.Pp
325Enumeration values are all uppercase.
326.Bd -literal
327enum enumtype { ONE, TWO } et;
328.Ed
329.Pp
330The use of internal_underscores in identifiers is preferred over
331camelCase or TitleCase.
332.Pp
333In declarations, do not put any whitespace between asterisks and
334adjacent tokens, except for tokens that are identifiers related to
335types.
336(These identifiers are the names of basic types, type
337qualifiers, and
338.Ic typedef Ns -names
339other than the one being declared.)
340Separate these identifiers from asterisks using a single space.
341.Pp
342When declaring variables in structures, declare them sorted by use, then
343by size (largest to smallest), and then in alphabetical order.
344The first category normally does not apply, but there are exceptions.
345Each one gets its own line.
346Try to make the structure
347readable by aligning the member names using either one or two tabs
348depending upon your judgment.
349You should use one tab only if it suffices to align at least 90% of
350the member names.
351Names following extremely long types
352should be separated by a single space.
353.Pp
354Major structures should be declared at the top of the file in which they
355are used, or in separate header files if they are used in multiple
356source files.
357Use of the structures should be by separate declarations
358and should be
359.Ic extern
360if they are declared in a header file.
361.Bd -literal
362struct foo {
363	struct foo	*next;		/* List of active foo. */
364	struct mumble	amumble;	/* Comment for mumble. */
365	int		bar;		/* Try to align the comments. */
366	struct verylongtypename *baz;	/* Does not fit in 2 tabs. */
367};
368struct foo *foohead;			/* Head of global foo list. */
369.Ed
370.Pp
371Use
372.Xr queue 3
373macros rather than rolling your own lists, whenever possible.
374Thus,
375the previous example would be better written:
376.Bd -literal
377#include <sys/queue.h>
378
379struct foo {
380	LIST_ENTRY(foo)	link;		/* Use queue macros for foo lists. */
381	struct mumble	amumble;	/* Comment for mumble. */
382	int		bar;		/* Try to align the comments. */
383	struct verylongtypename *baz;	/* Does not fit in 2 tabs. */
384};
385LIST_HEAD(, foo) foohead;		/* Head of global foo list. */
386.Ed
387.Pp
388Avoid using typedefs for structure types.
389Typedefs are problematic because they do not properly hide their
390underlying type; for example you need to know if the typedef is
391the structure itself or a pointer to the structure.
392In addition they must be declared exactly once, whereas an
393incomplete structure type can be mentioned as many times as
394necessary.
395Typedefs are difficult to use in stand-alone header files:
396the header that defines the typedef must be included
397before the header that uses it, or by the header that uses
398it (which causes namespace pollution), or there must be a
399back-door mechanism for obtaining the typedef.
400.Pp
401When convention requires a
402.Ic typedef ,
403make its name match the struct tag.
404Avoid typedefs ending in
405.Dq Li _t ,
406except as specified in Standard C or by POSIX.
407.Bd -literal
408/* Make the structure name match the typedef. */
409typedef	struct bar {
410	int	level;
411} BAR;
412typedef	int		foo;		/* This is foo. */
413typedef	const long	baz;		/* This is baz. */
414.Ed
415.Pp
416All functions are prototyped somewhere.
417.Pp
418Function prototypes for private functions (i.e., functions not used
419elsewhere) go at the top of the first source module.
420Functions
421local to one source module should be declared
422.Ic static .
423.Pp
424Functions used from other parts of the kernel are prototyped in the
425relevant include file.
426Function prototypes should be listed in a logical order, preferably
427alphabetical unless there is a compelling reason to use a different
428ordering.
429.Pp
430Functions that are used locally in more than one module go into a
431separate header file, e.g.,
432.Qq Pa extern.h .
433.Pp
434Do not use the
435.Dv __P
436macro.
437.Pp
438In general code can be considered
439.Dq "new code"
440when it makes up about 50% or more of the file(s) involved.
441This is enough
442to break precedents in the existing code and use the current
443.Nm
444guidelines.
445.Pp
446The kernel has a name associated with parameter types, e.g., in the kernel
447use:
448.Bd -literal
449void	function(int fd);
450.Ed
451.Pp
452In header files visible to userland applications, prototypes that are
453visible must use either
454.Dq protected
455names (ones beginning with an underscore)
456or no names with the types.
457It is preferable to use protected names.
458E.g., use:
459.Bd -literal
460void	function(int);
461.Ed
462.Pp
463or:
464.Bd -literal
465void	function(int _fd);
466.Ed
467.Pp
468Prototypes may have an extra space after a tab to enable function names
469to line up:
470.Bd -literal
471static char	*function(int _arg, const char *_arg2, struct foo *_arg3,
472		    struct bar *_arg4);
473static void	 usage(void);
474
475/*
476 * All major routines should have a comment briefly describing what
477 * they do.  The comment before the "main" routine should describe
478 * what the program does.
479 */
480int
481main(int argc, char *argv[])
482{
483	char *ep;
484	long num;
485	int ch;
486.Ed
487.Pp
488For consistency,
489.Xr getopt 3
490should be used to parse options.
491Options
492should be sorted in the
493.Xr getopt 3
494call and the
495.Ic switch
496statement, unless
497parts of the
498.Ic switch
499cascade.
500Elements in a
501.Ic switch
502statement that cascade should have a
503.Li FALLTHROUGH
504comment.
505Numerical arguments should be checked for accuracy.
506Code which is unreachable for non-obvious reasons may be marked /*
507.Li NOTREACHED
508*/.
509.Bd -literal
510	while ((ch = getopt(argc, argv, "abNn:")) != -1)
511		switch (ch) {		/* Indent the switch. */
512		case 'a':		/* Do not indent the case. */
513			aflag = 1;	/* Indent case body one tab. */
514			/* FALLTHROUGH */
515		case 'b':
516			bflag = 1;
517			break;
518		case 'N':
519			Nflag = 1;
520			break;
521		case 'n':
522			num = strtol(optarg, &ep, 10);
523			if (num <= 0 || *ep != '\e0') {
524				warnx("illegal number, -n argument -- %s",
525				    optarg);
526				usage();
527			}
528			break;
529		case '?':
530		default:
531			usage();
532		}
533	argc -= optind;
534	argv += optind;
535.Ed
536.Pp
537Space after keywords
538.Pq Ic if , while , for , return , switch .
539Two styles of braces
540.Ql ( \&{
541and
542.Ql \&} )
543are allowed for single line statements.
544Either they are used for all single statements, or
545they are used only where needed for clarity.
546Usage within a function should be consistent.
547Forever loops are done with
548.Ic for Ns 's ,
549not
550.Ic while Ns 's .
551.Bd -literal
552	for (p = buf; *p != '\e0'; ++p)
553		;	/* nothing */
554	for (;;)
555		stmt;
556	for (;;) {
557		z = a + really + long + statement + that + needs +
558		    two + lines + gets + indented + four + spaces +
559		    on + the + second + and + subsequent + lines;
560	}
561	for (;;) {
562		if (cond)
563			stmt;
564	}
565	if (val != NULL)
566		val = realloc(val, newsize);
567.Ed
568.Pp
569Parts of a
570.Ic for
571loop may be left empty.
572Do not put declarations
573inside blocks unless the routine is unusually complicated.
574.Bd -literal
575	for (; cnt < 15; cnt++) {
576		stmt1;
577		stmt2;
578	}
579.Ed
580.Pp
581Indentation is an 8 character tab.
582Second level indents are four spaces.
583If you have to wrap a long statement, put the operator at the end of the
584line.
585.Bd -literal
586	while (cnt < 20 && this_variable_name_is_too_long &&
587	    ep != NULL)
588		z = a + really + long + statement + that + needs +
589		    two + lines + gets + indented + four + spaces +
590		    on + the + second + and + subsequent + lines;
591.Ed
592.Pp
593Do not add whitespace at the end of a line, and only use tabs
594followed by spaces
595to form the indentation.
596Do not use more spaces than a tab will produce
597and do not use spaces in front of tabs.
598.Pp
599Closing and opening braces go on the same line as the
600.Ic else .
601Braces that are not necessary may be left out.
602.Bd -literal
603	if (test)
604		stmt;
605	else if (bar) {
606		stmt;
607		stmt;
608	} else
609		stmt;
610.Ed
611.Pp
612No spaces after function names.
613Commas have a space after them.
614No spaces
615after
616.Ql \&(
617or
618.Ql \&[
619or preceding
620.Ql \&]
621or
622.Ql \&)
623characters.
624.Bd -literal
625	error = function(a1, a2);
626	if (error != 0)
627		exit(error);
628.Ed
629.Pp
630Unary operators do not require spaces, binary operators do.
631Do not use parentheses unless they are required for precedence or unless the
632statement is confusing without them.
633Remember that other people may
634confuse easier than you.
635Do YOU understand the following?
636.Bd -literal
637	a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
638	k = !(l & FLAGS);
639.Ed
640.Pp
641Exits should be 0 on success, or 1 on failure.
642.Bd -literal
643	exit(0);	/*
644			 * Avoid obvious comments such as
645			 * "Exit 0 on success."
646			 */
647}
648.Ed
649.Pp
650The function type should be on a line by itself
651preceding the function.
652The opening brace of the function body should be
653on a line by itself.
654.Bd -literal
655static char *
656function(int a1, int a2, float fl, int a4)
657{
658.Ed
659.Pp
660When declaring variables in functions declare them sorted by size,
661then in alphabetical order; multiple ones per line are okay.
662If a line overflows reuse the type keyword.
663.Pp
664Be careful to not obfuscate the code by initializing variables in
665the declarations.
666Use this feature only thoughtfully.
667DO NOT use function calls in initializers.
668.Bd -literal
669	struct foo one, *two;
670	double three;
671	int *four, five;
672	char *six, seven, eight, nine, ten, eleven, twelve;
673
674	four = myfunction();
675.Ed
676.Pp
677Do not declare functions inside other functions; ANSI C says that
678such declarations have file scope regardless of the nesting of the
679declaration.
680Hiding file declarations in what appears to be a local
681scope is undesirable and will elicit complaints from a good compiler.
682.Pp
683Casts and
684.Ic sizeof Ns 's
685are not followed by a space.
686Note that
687.Xr indent 1
688does not understand this rule.
689.Ic sizeof Ns 's
690are written with parenthesis always.
691The redundant parenthesis rules do not apply to
692.Fn sizeof var
693instances.
694.Pp
695.Dv NULL
696is the preferred null pointer constant.
697Use
698.Dv NULL
699instead of
700.Vt ( "type *" ) Ns 0
701or
702.Vt ( "type *" ) Ns Dv NULL
703in contexts where the compiler knows the
704type, e.g., in assignments.
705Use
706.Vt ( "type *" ) Ns Dv NULL
707in other contexts,
708in particular for all function args.
709(Casting is essential for
710variadic args and is necessary for other args if the function prototype
711might not be in scope.)
712Test pointers against
713.Dv NULL ,
714e.g., use:
715.Bd -literal
716(p = f()) == NULL
717.Ed
718.Pp
719not:
720.Bd -literal
721!(p = f())
722.Ed
723.Pp
724Do not use
725.Ic \&!
726for tests unless it is a boolean, e.g., use:
727.Bd -literal
728if (*p == '\e0')
729.Ed
730.Pp
731not:
732.Bd -literal
733if (!*p)
734.Ed
735.Pp
736Routines returning
737.Vt "void *"
738should not have their return values cast
739to any pointer type.
740.Pp
741Values in
742.Ic return
743statements should be enclosed in parentheses.
744.Pp
745Use
746.Xr err 3
747or
748.Xr warn 3 ,
749do not roll your own.
750.Bd -literal
751	if ((four = malloc(sizeof(struct foo))) == NULL)
752		err(1, (char *)NULL);
753	if ((six = (int *)overflow()) == NULL)
754		errx(1, "number overflowed");
755	return (eight);
756}
757.Ed
758.Pp
759When converting K&R style declarations to ANSI style, preserve
760any comments about parameters.
761.Pp
762Long parameter lists are wrapped with a normal four space indent.
763.Pp
764Variable numbers of arguments should look like this:
765.Bd -literal
766#include <stdarg.h>
767
768void
769vaf(const char *fmt, ...)
770{
771	va_list ap;
772
773	va_start(ap, fmt);
774	STUFF;
775	va_end(ap);
776	/* No return needed for void functions. */
777}
778
779static void
780usage(void)
781{
782	/* Optional blank line goes here. */
783.Ed
784.Pp
785Optionally, insert a blank line at the beginning of functions with no local
786variables.
787Older versions of this
788.Nm
789document required the blank line convention, so it is widely used in existing
790code.
791.Pp
792Do not insert a blank line at the beginning of functions with local variables.
793Instead, these should have local variable declarations first, followed by one
794blank line, followed by the first statement.
795.Pp
796Use
797.Xr printf 3 ,
798not
799.Xr fputs 3 ,
800.Xr puts 3 ,
801.Xr putchar 3 ,
802whatever; it is faster and usually cleaner, not
803to mention avoiding stupid bugs.
804.Pp
805Usage statements should look like the manual pages
806.Sx SYNOPSIS .
807The usage statement should be structured in the following order:
808.Bl -enum
809.It
810Options without operands come first,
811in alphabetical order,
812inside a single set of brackets
813.Ql ( \&[
814and
815.Ql \&] ) .
816.It
817Options with operands come next,
818also in alphabetical order,
819with each option and its argument inside its own pair of brackets.
820.It
821Required arguments
822(if any)
823are next,
824listed in the order they should be specified on the command line.
825.It
826Finally,
827any optional arguments should be listed,
828listed in the order they should be specified,
829and all inside brackets.
830.El
831.Pp
832A bar
833.Pq Ql \&|
834separates
835.Dq either-or
836options/arguments,
837and multiple options/arguments which are specified together are
838placed in a single set of brackets.
839.Bd -literal -offset 4n
840"usage: f [-aDde] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\en"
841"usage: f [-a | -b] [-c [-dEe] [-n number]]\en"
842.Ed
843.Bd -literal
844	(void)fprintf(stderr, "usage: f [-ab]\en");
845	exit(1);
846}
847.Ed
848.Pp
849Note that the manual page options description should list the options in
850pure alphabetical order.
851That is, without regard to whether an option takes arguments or not.
852The alphabetical ordering should take into account the case ordering
853shown above.
854.Pp
855New core kernel code should be reasonably compliant with the
856.Nm
857guides.
858The guidelines for third-party maintained modules and device drivers are more
859relaxed but at a minimum should be internally consistent with their style.
860.Pp
861Stylistic changes (including whitespace changes) are hard on the source
862repository and are to be avoided without good reason.
863Code that is approximately
864.Fx
865KNF
866.Nm
867compliant in the repository must not diverge from compliance.
868.Pp
869Whenever possible, code should be run through a code checker
870(e.g., various static analyzers or
871.Nm cc Fl Wall )
872and produce minimal warnings.
873.Sh FILES
874.Bl -tag -width indent
875.It Pa /usr/src/tools/tools/editing/freebsd.el
876An Emacs plugin to follow the
877.Fx
878.Nm
879indentation rules.
880.It Pa /usr/src/tools/tools/editing/freebsd.vim
881A Vim plugin to follow the
882.Fx
883.Nm
884indentation rules.
885.El
886.Sh SEE ALSO
887.Xr indent 1 ,
888.Xr err 3 ,
889.Xr warn 3 ,
890.Xr style.Makefile 5 ,
891.Xr style.lua 9
892.Sh HISTORY
893This manual page is largely based on the
894.Pa src/admin/style/style
895file from the
896.Bx 4.4 Lite2
897release, with occasional updates to reflect the current practice and
898desire of the
899.Fx
900project.
901.Pa src/admin/style/style
902is a codification by the CSRG of the programming style of Ken Thompson and
903Dennis Ritchie in
904.At v6 .
905