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