Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Sep 2008 19:31:45 GMT
From:      Bruce Cran <bruce@cran.org.uk>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   docs/127219: [patch] style(9) is inconsistent regarding usage of sysexits(3)
Message-ID:  <200809081931.m88JVjMs066666@www.freebsd.org>
Resent-Message-ID: <200809081940.m88Je2Qq039328@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         127219
>Category:       docs
>Synopsis:       [patch] style(9) is inconsistent regarding usage of sysexits(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 08 19:40:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Bruce Cran
>Release:        7.0-RELEASE-p3
>Organization:
>Environment:
FreeBSD tau.draftnet 7.0-RELEASE-p3 FreeBSD 7.0-RELEASE-p3 #1: Mon Aug  4 00:11:11 BST 2008     brucec@tau.draftnet:/usr/obj/usr/src/sys/MYKERNEL  amd64
>Description:
style(9) is inconsistent regarding the usage of sysexits(3): at one point it says

Exits should be 0 on success, or according to the predefined values in sysexits(3).

But in a later example:

 Use err(3) or warn(3), do not roll your own.

             if ((four = malloc(sizeof(struct foo))) == NULL)
                     err(1, (char *)NULL);
             if ((six = (int *)overflow()) == NULL)
                     errx(1, "number overflowed");
             return (eight);
     }

err and errx exit with a code of 1, which is incorrect according to the previous statement.  Better exit codes might be EX_OSERR and EX_DATAERR.

Also, the cast of NULL to char * isn't required.
>How-To-Repeat:
man 9 style
>Fix:


Patch attached with submission follows:

--- /usr/src/share/man/man9/style.9	2007-01-28 20:51:04.000000000 +0000
+++ style.9	2008-09-08 20:20:31.000000000 +0100
@@ -716,9 +716,9 @@
 do not roll your own.
 .Bd -literal
 	if ((four = malloc(sizeof(struct foo))) == NULL)
-		err(1, (char *)NULL);
+		err(EX_OSERR, NULL);
 	if ((six = (int *)overflow()) == NULL)
-		errx(1, "number overflowed");
+		errx(EX_DATAERR, "number overflowed");
 	return (eight);
 }
 .Ed


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809081931.m88JVjMs066666>