Bug 127220

Summary: [patch] err(3) suggests using exit values from sysexits(3) but examples don't
Product: Documentation Reporter: Rebecca Cran <bcran>
Component: Books & ArticlesAssignee: Robert Watson <rwatson>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Rebecca Cran freebsd_committer freebsd_triage 2008-09-08 21:00:11 UTC
err(3) suggests that exit codes from sysexits(3) be used for the eval parameter, but fails to use them in the examples.

Fix: Patch attached with submission follows:
How-To-Repeat: man 3 err
Comment 1 Robert Watson freebsd_committer freebsd_triage 2008-10-31 14:49:03 UTC
State Changed
From-To: open->analyzed

Seems reasonable. 


Comment 2 Robert Watson freebsd_committer freebsd_triage 2008-10-31 14:49:03 UTC
Responsible Changed
From-To: freebsd-doc->rwatson

Grab ownership since I'll merge this.
Comment 3 Robert Watson freebsd_committer freebsd_triage 2008-10-31 15:18:03 UTC
---------- 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
Comment 4 Robert Watson freebsd_committer freebsd_triage 2008-10-31 15:21:05 UTC
State Changed
From-To: analyzed->patched

Committed to head; in patched state until MFC.
Comment 5 Robert Watson freebsd_committer freebsd_triage 2009-02-01 18:46:11 UTC
State Changed
From-To: patched->closed

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!