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