From nobody@FreeBSD.org  Mon Sep  8 19:58:42 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5CAE8106567A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Sep 2008 19:58:42 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 4F2E88FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Sep 2008 19:58:42 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m88JwgIE080012
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 8 Sep 2008 19:58:42 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m88JwgPK080011;
	Mon, 8 Sep 2008 19:58:42 GMT
	(envelope-from nobody)
Message-Id: <200809081958.m88JwgPK080011@www.freebsd.org>
Date: Mon, 8 Sep 2008 19:58:42 GMT
From: Bruce Cran <bruce@cran.org.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] err(3) suggests using exit values from sysexits(3) but examples don't
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         127220
>Category:       docs
>Synopsis:       [patch] err(3) suggests using exit values from sysexits(3) but examples don't
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rwatson
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 08 20:00:11 UTC 2008
>Closed-Date:    Sun Feb 01 18:46:57 UTC 2009
>Last-Modified:  Sun Feb 01 18:46:57 UTC 2009
>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:
err(3) suggests that exit codes from sysexits(3) be used for the eval parameter, but fails to use them in the examples.
>How-To-Repeat:
man 3 err
>Fix:


Patch attached with submission follows:

--- /usr/src/lib/libc/gen/err.3	2007-01-09 00:27:53.000000000 +0000
+++ err.3	2008-09-08 20:54:20.000000000 +0100
@@ -178,15 +178,15 @@
 Display the current errno information string and exit:
 .Bd -literal -offset indent
 if ((p = malloc(size)) == NULL)
-	err(1, NULL);
+	err(EX_OSERR, NULL);
 if ((fd = open(file_name, O_RDONLY, 0)) == -1)
-	err(1, "%s", file_name);
+	err(EX_NOINPUT, "%s", file_name);
 .Ed
 .Pp
 Display an error message and exit:
 .Bd -literal -offset indent
 if (tm.tm_hour < START_TIME)
-	errx(1, "too early, wait until %s", start_time_string);
+	errx(EX_DATAERR, "too early, wait until %s", start_time_string);
 .Ed
 .Pp
 Warn of an error:
@@ -195,7 +195,7 @@
 	warnx("%s: %s: trying the block device",
 	    raw_device, strerror(errno));
 if ((fd = open(block_device, O_RDONLY, 0)) == -1)
-	err(1, "%s", block_device);
+	err(EX_OSFILE, "%s", block_device);
 .Ed
 .Pp
 Warn of an error without using the global variable


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: rwatson 
State-Changed-When: Fri Oct 31 14:49:03 UTC 2008 
State-Changed-Why:  
Seems reasonable. 


Responsible-Changed-From-To: freebsd-doc->rwatson 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Fri Oct 31 14:49:03 UTC 2008 
Responsible-Changed-Why:  
Grab ownership since I'll merge this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127220 

From: Robert Watson <rwatson@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: docs/127220: svn commit: r184511 - head/lib/libc/gen (fwd)
Date: Fri, 31 Oct 2008 15:18:03 +0000 (GMT)

 ---------- Forwarded message ----------
 Date: Fri, 31 Oct 2008 15:14:41 +0000 (UTC)
 From: Robert Watson <rwatson@FreeBSD.org>
 To: src-committers@freebsd.org, svn-src-all@freebsd.org,
      svn-src-head@freebsd.org
 Subject: svn commit: r184511 - head/lib/libc/gen
 
 Author: rwatson
 Date: Fri Oct 31 15:14:40 2008
 New Revision: 184511
 URL: http://svn.freebsd.org/changeset/base/184511
 
 Log:
    In example use of err(3) and errx(3), use sysexits(3) constants.
 
    MFC after:	3 days
    Submitted by:	Bruce Cran <bruce at cran dot org dot uk>
 
 Modified:
    head/lib/libc/gen/err.3
 
 Modified: head/lib/libc/gen/err.3
 ==============================================================================
 --- head/lib/libc/gen/err.3	Fri Oct 31 15:11:01 2008	(r184510)
 +++ head/lib/libc/gen/err.3	Fri Oct 31 15:14:40 2008	(r184511)
 @@ -178,15 +178,16 @@ or a null pointer
   Display the current errno information string and exit:
   .Bd -literal -offset indent
   if ((p = malloc(size)) == NULL)
 -	err(1, NULL);
 +	err(EX_OSERR, NULL);
   if ((fd = open(file_name, O_RDONLY, 0)) == -1)
 -	err(1, "%s", file_name);
 +	err(EX_NOINPUT, "%s", file_name);
   .Ed
   .Pp
   Display an error message and exit:
   .Bd -literal -offset indent
   if (tm.tm_hour < START_TIME)
 -	errx(1, "too early, wait until %s", start_time_string);
 +	errx(EX_DATAERR, "too early, wait until %s",
 +	    start_time_string);
   .Ed
   .Pp
   Warn of an error:
 @@ -195,7 +196,7 @@ if ((fd = open(raw_device, O_RDONLY, 0))
   	warnx("%s: %s: trying the block device",
   	    raw_device, strerror(errno));
   if ((fd = open(block_device, O_RDONLY, 0)) == -1)
 -	err(1, "%s", block_device);
 +	err(EX_OSFILE, "%s", block_device);
   .Ed
   .Pp
   Warn of an error without using the global variable
State-Changed-From-To: analyzed->patched 
State-Changed-By: rwatson 
State-Changed-When: Fri Oct 31 15:21:05 UTC 2008 
State-Changed-Why:  
Committed to head; in patched state until MFC. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127220 
State-Changed-From-To: patched->closed 
State-Changed-By: rwatson 
State-Changed-When: Sun Feb 1 18:46:11 UTC 2009 
State-Changed-Why:  
After initially committing this patch, there seemed to be a strong 
consensus among interested developers that this was not, in fact, 
the preferred style, so I've backed it out.  Sorry about that! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=127220 
>Unformatted:
