Module Name: src
Committed By: christos
Date: Tue Jan 12 14:45:31 UTC 2010
Modified Files:
src/usr.bin/mail: fio.c lex.c list.c main.c names.c strings.c temp.c
Log Message:
error message cleanup
- 1 -> EXIT_FAILURE
- fprintf(stderr, -> warnx(
- better warning messages
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/mail/fio.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/mail/lex.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/mail/list.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/mail/main.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/mail/names.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/mail/strings.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/mail/temp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/mail/fio.c
diff -u src/usr.bin/mail/fio.c:1.33 src/usr.bin/mail/fio.c:1.34
--- src/usr.bin/mail/fio.c:1.33 Sat Apr 11 10:22:32 2009
+++ src/usr.bin/mail/fio.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fio.c,v 1.33 2009/04/11 14:22:32 christos Exp $ */
+/* $NetBSD: fio.c,v 1.34 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: fio.c,v 1.33 2009/04/11 14:22:32 christos Exp $");
+__RCSID("$NetBSD: fio.c,v 1.34 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -130,7 +130,8 @@
size = (nmsgCount + 1) * sizeof(*nmessage);
nmessage = realloc(omessage, size);
if (nmessage == NULL)
- err(1, "Insufficient memory for %d messages", nmsgCount);
+ err(EXIT_FAILURE,
+ "Insufficient memory for %d messages", nmsgCount);
if (omsgCount == 0 || omessage == NULL)
dot = nmessage;
else
@@ -350,7 +351,7 @@
(void)fflush(otf);
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), SEEK_SET) < 0)
- err(1, "fseek");
+ err(EXIT_FAILURE, "fseek");
return itf;
}
@@ -476,7 +477,7 @@
l = read(pivec[0], xname, sizeof(xname));
(void)close(pivec[0]);
if (wait_child(pid) < 0 && WTERMSIG(wait_status) != SIGPIPE) {
- (void)fprintf(stderr, "\"%s\": Expansion failed.\n", name);
+ warnx("Expansion `%s' failed [%x]", cmdbuf, wait_status);
return NULL;
}
if (l < 0) {
@@ -484,11 +485,11 @@
return NULL;
}
if (l == 0) {
- (void)fprintf(stderr, "\"%s\": No match.\n", name);
+ warnx("No match for `%s'", name);
return NULL;
}
if (l == sizeof(xname)) {
- (void)fprintf(stderr, "\"%s\": Expansion buffer overflow.\n", name);
+ warnx("Expansion buffer overflow for `%s'", name);
return NULL;
}
xname[l] = '\0';
@@ -496,7 +497,7 @@
continue;
cp[1] = '\0';
if (strchr(xname, ' ') && stat(xname, &sbuf) < 0) {
- (void)fprintf(stderr, "\"%s\": Ambiguous.\n", name);
+ warnx("Ambiguous expansion for `%s'", name);
return NULL;
}
return savestr(xname);
Index: src/usr.bin/mail/lex.c
diff -u src/usr.bin/mail/lex.c:1.38 src/usr.bin/mail/lex.c:1.39
--- src/usr.bin/mail/lex.c:1.38 Tue Jul 14 17:15:48 2009
+++ src/usr.bin/mail/lex.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.38 2009/07/14 21:15:48 apb Exp $ */
+/* $NetBSD: lex.c,v 1.39 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: lex.c,v 1.38 2009/07/14 21:15:48 apb Exp $");
+__RCSID("$NetBSD: lex.c,v 1.39 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -176,7 +176,7 @@
if ((ibuf = Fopen(name, "r")) == NULL) {
if (!isedit && errno == ENOENT)
goto nomail;
- warn("%s", name);
+ warn("Can't open `%s'", name);
return -1;
}
@@ -239,10 +239,10 @@
"%s/mail.RxXXXXXXXXXX", tmpdir);
if ((fd = mkstemp(tempname)) == -1 ||
(otf = fdopen(fd, "w")) == NULL)
- err(1, "%s", tempname);
+ err(EXIT_FAILURE, "Can't create tmp file `%s'", tempname);
(void)fcntl(fileno(otf), F_SETFD, FD_CLOEXEC);
if ((itf = fopen(tempname, "r")) == NULL)
- err(1, "%s", tempname);
+ err(EXIT_FAILURE, "Can't create tmp file `%s'", tempname);
(void)fcntl(fileno(itf), F_SETFD, FD_CLOEXEC);
(void)rm(tempname);
setptr(ibuf, (off_t)0);
@@ -747,7 +747,7 @@
break;
default:
- errx(1, "Unknown argtype");
+ errx(EXIT_FAILURE, "Unknown argtype");
}
out:
Index: src/usr.bin/mail/list.c
diff -u src/usr.bin/mail/list.c:1.25 src/usr.bin/mail/list.c:1.26
--- src/usr.bin/mail/list.c:1.25 Fri Apr 10 09:08:25 2009
+++ src/usr.bin/mail/list.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: list.c,v 1.25 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: list.c,v 1.26 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: list.c,v 1.25 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: list.c,v 1.26 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -427,7 +427,7 @@
regret(int token)
{
if (++regretp >= REGDEP)
- errx(1, "Too many regrets");
+ errx(EXIT_FAILURE, "Too many regrets");
regretstack[regretp] = token;
lexstring[sizeof(lexstring) - 1] = '\0';
string_stack[regretp] = savestr(lexstring);
Index: src/usr.bin/mail/main.c
diff -u src/usr.bin/mail/main.c:1.30 src/usr.bin/mail/main.c:1.31
--- src/usr.bin/mail/main.c:1.30 Fri Apr 10 09:08:25 2009
+++ src/usr.bin/mail/main.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.30 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: main.c,v 1.31 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: main.c,v 1.30 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.31 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -387,9 +387,9 @@
* Check for inconsistent arguments.
*/
if (to == NULL && (subject != NULL || cc != NULL || bcc != NULL))
- errx(1, "You must specify direct recipients with -s, -c, or -b.");
+ errx(EXIT_FAILURE, "You must specify direct recipients with -s, -c, or -b.");
if (ef != NULL && to != NULL) {
- errx(1, "Cannot give -f and people to send to.");
+ errx(EXIT_FAILURE, "Cannot give -f and people to send to.");
}
if (Hflag != 0 && to != NULL)
errx(EXIT_FAILURE, "Cannot give -H and people to send to.");
Index: src/usr.bin/mail/names.c
diff -u src/usr.bin/mail/names.c:1.27 src/usr.bin/mail/names.c:1.28
--- src/usr.bin/mail/names.c:1.27 Mon Oct 29 19:20:38 2007
+++ src/usr.bin/mail/names.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: names.c,v 1.27 2007/10/29 23:20:38 christos Exp $ */
+/* $NetBSD: names.c,v 1.28 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: names.c,v 1.27 2007/10/29 23:20:38 christos Exp $");
+__RCSID("$NetBSD: names.c,v 1.28 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -533,7 +533,7 @@
n = np;
if ((t = count(n)) == 0)
- errx(1, "No names to unpack");
+ errx(EXIT_FAILURE, "No names to unpack");
/*
* Compute the number of extra arguments we will need.
* We need at least two extra -- one for "mail" and one for
Index: src/usr.bin/mail/strings.c
diff -u src/usr.bin/mail/strings.c:1.17 src/usr.bin/mail/strings.c:1.18
--- src/usr.bin/mail/strings.c:1.17 Fri Apr 10 09:08:25 2009
+++ src/usr.bin/mail/strings.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: strings.c,v 1.17 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: strings.c,v 1.18 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)strings.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: strings.c,v 1.17 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: strings.c,v 1.18 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -91,12 +91,12 @@
idx++;
}
if (sp >= &stringdope[NSPACE])
- errx(1, "String too large");
+ errx(EXIT_FAILURE, "String too large");
if (sp->s_topFree == NULL) {
idx = (int)(sp - &stringdope[0]);
sp->s_topFree = malloc(STRINGSIZE << idx);
if (sp->s_topFree == NULL)
- errx(1, "No room for space %d", idx);
+ errx(EXIT_FAILURE, "No room for space %d", idx);
sp->s_nextFree = sp->s_topFree;
sp->s_nleft = STRINGSIZE << idx;
}
Index: src/usr.bin/mail/temp.c
diff -u src/usr.bin/mail/temp.c:1.21 src/usr.bin/mail/temp.c:1.22
--- src/usr.bin/mail/temp.c:1.21 Tue Nov 28 13:45:32 2006
+++ src/usr.bin/mail/temp.c Tue Jan 12 09:45:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: temp.c,v 1.21 2006/11/28 18:45:32 christos Exp $ */
+/* $NetBSD: temp.c,v 1.22 2010/01/12 14:45:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)temp.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: temp.c,v 1.21 2006/11/28 18:45:32 christos Exp $");
+__RCSID("$NetBSD: temp.c,v 1.22 2010/01/12 14:45:31 christos Exp $");
#endif
#endif /* not lint */
@@ -73,7 +73,7 @@
if (myname != NULL) {
if (getuserid(myname) < 0)
- errx(1, "\"%s\" is not a user of this system", myname);
+ errx(EXIT_FAILURE, "`%s' is not a user of this system", myname);
}
else {
if ((cp = username()) == NULL) {