| Summary: | [patch] style(9) is inconsistent regarding usage of sysexits(3) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Documentation | Reporter: | Rebecca Cran <bcran> | ||||
| Component: | Books & Articles | Assignee: | Robert Watson <rwatson> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | Latest | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
State Changed From-To: open->analyzed This seems reasonable. Responsible Changed From-To: freebsd-doc->rwatson Grab ownership as I'll commit this. ---------- Forwarded message ---------- Date: Fri, 31 Oct 2008 14:47:15 +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: r184509 - head/share/man/man9 Author: rwatson Date: Fri Oct 31 14:47:15 2008 New Revision: 184509 URL: http://svn.freebsd.org/changeset/base/184509 Log: In style(9) examples of err() and errx(), use sysexits(3) errors rather than returning 1. Submitted by: Bruce Cran <bruce at cran dot org dot uk> MFC after: 3 days Modified: head/share/man/man9/style.9 Modified: head/share/man/man9/style.9 ============================================================================== --- head/share/man/man9/style.9 Fri Oct 31 14:40:21 2008 (r184508) +++ head/share/man/man9/style.9 Fri Oct 31 14:47:15 2008 (r184509) @@ -716,9 +716,9 @@ or 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 State Changed From-To: analyzed->patched Committed to head; placed in patched state until MFC. State Changed From-To: patched->closed As with docs/127220, it turns out that the proposed patch does not capture the preferred code style, so I've backed it out. |
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. Fix: Patch attached with submission follows: How-To-Repeat: man 9 style