.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: style.9,v 1.62 2015/10/05 01:22:34 deraadt Exp $
+.\" $OpenBSD: style.9,v 1.63 2015/10/05 21:59:29 tedu Exp $
.\"
.Dd $Mdocdate: October 5 2015 $
.Dt STYLE 9
Elements in a switch statement that cascade should have a FALLTHROUGH comment.
Numerical arguments should be checked for accuracy.
.Bd -literal -offset indent
-while ((ch = getopt(argc, argv, "abn:")) != -1)
+while ((ch = getopt(argc, argv, "abn:")) != -1) {
switch (ch) { /* Indent the switch. */
case 'a': /* Don't indent the case. */
aflag = 1;
default:
usage();
}
+}
argc -= optind;
argv += optind;
.Ed
.Pp
Exits should be 0 on success, or non-zero for errors.
.Bd -literal -offset indent
-exit(0); /*
- * Avoid obvious comments such as
- * "Exit 0 on success."
- */
-}
+/*
+ * Avoid obvious comments such as
+ * "Exit 0 on success."
+ */
+exit(0);
.Ed
.Pp
The function type should be on a line by itself
if ((six = (int *)overflow()) == NULL)
errx(1, "Number overflowed.");
return (eight);
-}
.Ed
.Pp
Old-style function declarations look like this:
.Bd -literal -offset indent
(void)fprintf(stderr, "usage: %s [-ab]\en", __progname);
exit(1);
-}
.Ed
.Pp
New core kernel code should be reasonably compliant with the style guides.