History log of /netbsd-current/share/misc/style
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.77 29-Jan-2024 rin

style: One more typo, NFC


# 1.76 24-Jan-2024 rin

style: Fix typo, NFC

"it it" --> "it is" (across a newline)


# 1.75 07-Aug-2023 riastradh

style(5): Advise against new struct typedefs and explain why.

Proposed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/07/11/msg028950.html

Positive feedback to general concept, negative feedback to specifics
and phrasing of the first iteration but no objections to latest
iteration after several weeks at:
https://mail-index.netbsd.org/tech-kern/2023/07/16/msg028994.html


# 1.74 21-Apr-2023 rillig

style: remove mentions of ANSI C

The distinction between traditional C and ISO C90 or later is no longer
needed in the style guide. Any old-style code is caught by the
compilers.

https://mail-index.netbsd.org/tech-userlevel/2023/04/15/msg013768.html
https://mail-index.netbsd.org/tech-userlevel/2023/04/17/msg013776.html


# 1.73 17-Apr-2023 dholland

share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


# 1.72 15-Apr-2023 rillig

style: fix spelling of plural parentheses


# 1.71 14-Apr-2023 rillig

style: don't require sorting variables in functions

Sorting the variables by size would be platform-dependent and thus is
not possible.

Sorting the variables alphabetically may or may not make the code easier
to read, and the example given below that rule doesn't follow it,
otherwise the correct order would be 'eight, eleven, nine, ten,
thirteen, twelve'.

https://mail-index.netbsd.org/tech-userlevel/2023/04/11/msg013749.html


# 1.70 11-Apr-2023 riastradh

style(5): Omit redundant proscription against .c externs in previous.


# 1.69 30-Mar-2023 riastradh

style(5): Forbid extern in .c files.

Discussed on tech-userlevel (bcc tech-kern):
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html


# 1.68 14-Feb-2023 jschauma

exit with EXIT_FAILURE, not 1, as elsewhere


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.76 24-Jan-2024 rin

style: Fix typo, NFC

"it it" --> "it is" (across a newline)


# 1.75 07-Aug-2023 riastradh

style(5): Advise against new struct typedefs and explain why.

Proposed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/07/11/msg028950.html

Positive feedback to general concept, negative feedback to specifics
and phrasing of the first iteration but no objections to latest
iteration after several weeks at:
https://mail-index.netbsd.org/tech-kern/2023/07/16/msg028994.html


# 1.74 21-Apr-2023 rillig

style: remove mentions of ANSI C

The distinction between traditional C and ISO C90 or later is no longer
needed in the style guide. Any old-style code is caught by the
compilers.

https://mail-index.netbsd.org/tech-userlevel/2023/04/15/msg013768.html
https://mail-index.netbsd.org/tech-userlevel/2023/04/17/msg013776.html


# 1.73 17-Apr-2023 dholland

share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


# 1.72 15-Apr-2023 rillig

style: fix spelling of plural parentheses


# 1.71 14-Apr-2023 rillig

style: don't require sorting variables in functions

Sorting the variables by size would be platform-dependent and thus is
not possible.

Sorting the variables alphabetically may or may not make the code easier
to read, and the example given below that rule doesn't follow it,
otherwise the correct order would be 'eight, eleven, nine, ten,
thirteen, twelve'.

https://mail-index.netbsd.org/tech-userlevel/2023/04/11/msg013749.html


# 1.70 11-Apr-2023 riastradh

style(5): Omit redundant proscription against .c externs in previous.


# 1.69 30-Mar-2023 riastradh

style(5): Forbid extern in .c files.

Discussed on tech-userlevel (bcc tech-kern):
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html


# 1.68 14-Feb-2023 jschauma

exit with EXIT_FAILURE, not 1, as elsewhere


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.75 07-Aug-2023 riastradh

style(5): Advise against new struct typedefs and explain why.

Proposed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/07/11/msg028950.html

Positive feedback to general concept, negative feedback to specifics
and phrasing of the first iteration but no objections to latest
iteration after several weeks at:
https://mail-index.netbsd.org/tech-kern/2023/07/16/msg028994.html


# 1.74 21-Apr-2023 rillig

style: remove mentions of ANSI C

The distinction between traditional C and ISO C90 or later is no longer
needed in the style guide. Any old-style code is caught by the
compilers.

https://mail-index.netbsd.org/tech-userlevel/2023/04/15/msg013768.html
https://mail-index.netbsd.org/tech-userlevel/2023/04/17/msg013776.html


# 1.73 17-Apr-2023 dholland

share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


# 1.72 15-Apr-2023 rillig

style: fix spelling of plural parentheses


# 1.71 14-Apr-2023 rillig

style: don't require sorting variables in functions

Sorting the variables by size would be platform-dependent and thus is
not possible.

Sorting the variables alphabetically may or may not make the code easier
to read, and the example given below that rule doesn't follow it,
otherwise the correct order would be 'eight, eleven, nine, ten,
thirteen, twelve'.

https://mail-index.netbsd.org/tech-userlevel/2023/04/11/msg013749.html


# 1.70 11-Apr-2023 riastradh

style(5): Omit redundant proscription against .c externs in previous.


# 1.69 30-Mar-2023 riastradh

style(5): Forbid extern in .c files.

Discussed on tech-userlevel (bcc tech-kern):
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html


# 1.68 14-Feb-2023 jschauma

exit with EXIT_FAILURE, not 1, as elsewhere


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.74 21-Apr-2023 rillig

style: remove mentions of ANSI C

The distinction between traditional C and ISO C90 or later is no longer
needed in the style guide. Any old-style code is caught by the
compilers.

https://mail-index.netbsd.org/tech-userlevel/2023/04/15/msg013768.html
https://mail-index.netbsd.org/tech-userlevel/2023/04/17/msg013776.html


# 1.73 17-Apr-2023 dholland

share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


# 1.72 15-Apr-2023 rillig

style: fix spelling of plural parentheses


# 1.71 14-Apr-2023 rillig

style: don't require sorting variables in functions

Sorting the variables by size would be platform-dependent and thus is
not possible.

Sorting the variables alphabetically may or may not make the code easier
to read, and the example given below that rule doesn't follow it,
otherwise the correct order would be 'eight, eleven, nine, ten,
thirteen, twelve'.

https://mail-index.netbsd.org/tech-userlevel/2023/04/11/msg013749.html


# 1.70 11-Apr-2023 riastradh

style(5): Omit redundant proscription against .c externs in previous.


# 1.69 30-Mar-2023 riastradh

style(5): Forbid extern in .c files.

Discussed on tech-userlevel (bcc tech-kern):
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html


# 1.68 14-Feb-2023 jschauma

exit with EXIT_FAILURE, not 1, as elsewhere


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.73 17-Apr-2023 dholland

share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


# 1.72 15-Apr-2023 rillig

style: fix spelling of plural parentheses


# 1.71 14-Apr-2023 rillig

style: don't require sorting variables in functions

Sorting the variables by size would be platform-dependent and thus is
not possible.

Sorting the variables alphabetically may or may not make the code easier
to read, and the example given below that rule doesn't follow it,
otherwise the correct order would be 'eight, eleven, nine, ten,
thirteen, twelve'.

https://mail-index.netbsd.org/tech-userlevel/2023/04/11/msg013749.html


# 1.70 11-Apr-2023 riastradh

style(5): Omit redundant proscription against .c externs in previous.


# 1.69 30-Mar-2023 riastradh

style(5): Forbid extern in .c files.

Discussed on tech-userlevel (bcc tech-kern):
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html


# 1.68 14-Feb-2023 jschauma

exit with EXIT_FAILURE, not 1, as elsewhere


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.68 14-Feb-2023 jschauma

exit with EXIT_FAILURE, not 1, as elsewhere


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.67 30-Dec-2022 jkoshy

Move a style recommendation closer to the syntax that it describes.


# 1.66 30-Dec-2022 jkoshy

C99: Suggest using narrow scopes for loop indices.


# 1.65 29-Dec-2022 jkoshy

Terminate a sentence with a full stop.


Revision tags: netbsd-10-base
# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.64 10-Mar-2022 rillig

share/misc/style: lint no longer needs CONSTCOND in do-while-loops

Since usr.bin/xlint/lint1/tree.c 1.202 from 2021-01-31, lint recognizes
the common idiom 'do { ... } while (0)' and no longer complains about
its constant condition; see tests/usr.bin/xlint/lint1/msg_161.c.


# 1.63 10-Mar-2022 rillig

share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name. Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.62 28-Mar-2021 christos

Clarify and explain the rationale for parentheses in sizeof and return as
discussed.


# 1.61 28-Mar-2021 christos

- EXIT_FAILURE instead of 1
- %j instead of PRI for *intmax_t
- != -1 instead of < 0 for syscalls


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.60 29-Nov-2020 rillig

style: fix typo


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.59 02-Aug-2020 riastradh

Remove confusing advice about macros that might expand to nothing.

Such macros should not exist; as advised earlier in the file, they
should expand to `__nothing' (literally) from <sys/cdefs.h> which
itself expands to ((void)0) precisely so that the problem this advice
sought to avoid does not arise.


# 1.58 02-Aug-2020 riastradh

Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


# 1.57 02-Aug-2020 lukem

style: revert previous

I misintepreted the consensus.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.56 01-Aug-2020 lukem

style: prefer braces for single statement control statements

Prefer to use { braces } around single statements after
control statements, instead of discouraging them.

Per discussion on tech-userlevel & tech-kern, where the significant
majority of developers who responded (including current and former
core members) prefer this new style.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.55 26-Jul-2020 rillig

style: fix typo about enum constants being capitalized


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

branches: 1.53.16;
fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


# 1.54 28-Jan-2019 christos

document how we want to use __nothing


Revision tags: pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.53 23-May-2016 salazar

fix spelling mistakes


# 1.52 24-Oct-2015 christos

Amend variable initialization in the declarations comment.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.51 08-Mar-2013 christos

PR/47632: Supratim Chakraborty: Spelling Mistake for Variadic functions


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.50 27-Jun-2012 riastradh

branches: 1.50.2;
Elaborate and clarify rules about #include order.

ok christos


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.49 01-Sep-2011 christos

branches: 1.49.2;
explain NULL casts


# 1.48 27-Aug-2011 joerg

Prototyping main is silly and shouldn't be encouraged.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.47 30-Oct-2010 christos

make usage dead.


# 1.46 24-Apr-2010 christos

Be explicit about sizeof(*var) being preferred over sizeof(type).


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.45 15-Feb-2009 dholland

Avoid trailing whitespace. It is definitely against the style rules.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 mjf-devfs2-base
# 1.44 09-Sep-2008 jschauma

branches: 1.44.4;
move punctuation of a complete sentence into its parens


Revision tags: wrstuden-revivesa-base-2
# 1.43 20-Jul-2008 lukem

Remove the \n from the __COPYRIGHT example; what(1) stops extracting
at them, so we lose most of the message.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.42 16-Feb-2008 apb

branches: 1.42.4; 1.42.8;
Don't mention <machine/int_fmtio.h>; code should just
include <inttypes.h> to get intmax_t, PRIdMAX, and friends.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.41 20-Sep-2007 plunky

getopt uses : when an argument is expected


Revision tags: matt-mips64-base
# 1.40 26-May-2007 christos

branches: 1.40.4;
Fix reversed test and missing +; from Joerg Niendorf


# 1.39 13-Apr-2007 darcy

Add entry about making include files self-sufficient.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.38 02-Nov-2006 christos

update brace comments to reflect current reality.


Revision tags: abandoned-netbsd-4-base
# 1.37 25-Feb-2006 wiz

Mention the preferred option order in
getopt(), usage(), and man page.
Suggest describing newly added options in usage() and man page.


# 1.36 25-Aug-2005 briggs

Add some comments about using inttypes.h / int_fmtio.h macros.
Show use of PRIdMAX, PRIxMAX, PRId64, PRIx32, and refer to SCN*.
Inspired by comments from Roland Illig and others.


# 1.35 20-Aug-2005 rillig

Partly reverted my last change. I had forgotten that off_t is a signed
data type.


# 1.34 20-Aug-2005 rillig

Don't cast unsigned values to long long. They might overflow.


# 1.33 20-Aug-2005 rillig

Use exit(EXIT_FAILURE) instead of exit(1).


# 1.32 10-Jun-2005 junyoung

More clarification on uintN_t.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.31 03-Feb-2005 christos

Make comment more specific.


# 1.30 02-Feb-2005 christos

fix accidental join that made the comment look like functions that
return ``void *'' should not be cast'ed.


# 1.29 01-Feb-2005 christos

Add missing (void) cast to printf return.
Prefer returning from main rather than calling exit.


# 1.28 03-Jan-2005 wiz

Add uint32_t as example (so that it is implicitly clear we prefer the C99 types).


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 27-Sep-2003 simonb

Use uintN_t in code example instead of u_intN_t. Agrees with current
standards (and more importantly Klaus too :-).


# 1.26 05-Aug-2003 jmmv

Recommend EXIT_SUCCESS and EXIT_FAILURE for exit status, instead of directly
using 0 and 1 values, respectively.


# 1.25 17-Apr-2003 lukem

check strtol for ERANGE overflow too...


# 1.24 10-Mar-2003 lukem

There's no need anymore to protect __COPYRIGHT() and __RCSID() with:
#ifndef __lint
...
#endif


# 1.23 04-Mar-2003 fvdl

Return value style update (no parentheses)


# 1.22 02-Mar-2003 jhawk

Amend rev 1.21: there is insufficient concensus on #define<TAB>.
Permit any whitespace after #define, but mandate consistency of
TABs within a file.


# 1.21 23-Feb-2003 jhawk

Clarify that macros should be #define<TAB>; it's important to specify this
in the actual document, just not in the cvs logs (cf. rev 1.15).


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.20 23-Oct-2001 kleink

branches: 1.20.2;
Inspired by rev. 1.18: consistency, pull in <assert.h> for _DIAGASSERT().


# 1.19 23-Oct-2001 kleink

As discussed with Luke, add a short _DIAGASSERT(3) example.
Fixes PR lib/14324.


# 1.18 21-Feb-2001 cgd

add include of stdlib.h, for use of setprogname() & getprogname()


# 1.17 19-Feb-2001 cgd

nuke __progname, suggest setprogname() and getprogname()


# 1.16 06-Sep-2000 enami

Fix typos.


# 1.15 04-Sep-2000 lukem

- fix spelo
- be consistent with #define<TAB> for macros


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.14 10-Mar-2000 lukem

add example on how to printf 64 bit quantities


# 1.13 10-Mar-2000 lukem

fix comment around CONSTCOND


# 1.12 02-Mar-2000 lukem

major overhaul:
* require ANSI not K&R for prototypes, stdargs, etc
* document current practice for
- rcsids & copyright
- header file inclusion protection
- expressions, and multi-statement macros
- enum & struct decls
- empty and large statements
- wrapping long lines, prototypes, function decls


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.11 03-Jul-1999 abs

Fix error in example - from VaX#n8 <vax@linkdead.paranoia.com>


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.10 29-Jan-1999 scottr

Add a pointer to the indent(1) profile, and a disclaimer regarding same.


# 1.9 20-Jan-1999 lukem

provide a better parenthesis example. from Brian Grayson in [misc/6714]


# 1.8 01-Sep-1998 simonb

Function type declarations are manatory now.


# 1.7 09-Feb-1998 enami

Make C sentense end with `;'.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.6 30-Aug-1996 thorpej

RCS id police. Side effect: shows the RCS id style we prefer :-)


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.5 31-Mar-1996 scottr

getopt() returns -1 when the arg list is exhausted, not EOF. Ironic
that it should show up here...


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 10-Apr-1995 briggs

Minor grammatical nit: "have too" -> "have to."


# 1.3 19-Dec-1994 cgd

s/externs.h/extern.h/


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.2 26-Mar-1994 cgd

style guide


# 1.1 06-Aug-1993 cgd

overall source code style guide. it is king. revere it.