Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mail error message cleanup



details:   https://anonhg.NetBSD.org/src/rev/5da1e96bfd3c
branches:  trunk
changeset: 750727:5da1e96bfd3c
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 12 14:45:31 2010 +0000

description:
error message cleanup
- 1 -> EXIT_FAILURE
- fprintf(stderr, -> warnx(
- better warning messages

diffstat:

 usr.bin/mail/fio.c     |  17 +++++++++--------
 usr.bin/mail/lex.c     |  12 ++++++------
 usr.bin/mail/list.c    |   6 +++---
 usr.bin/mail/main.c    |   8 ++++----
 usr.bin/mail/names.c   |   6 +++---
 usr.bin/mail/strings.c |   8 ++++----
 usr.bin/mail/temp.c    |   6 +++---
 7 files changed, 32 insertions(+), 31 deletions(-)

diffs (262 lines):

diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/fio.c
--- a/usr.bin/mail/fio.c        Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/fio.c        Tue Jan 12 14:45:31 2010 +0000
@@ -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);
diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/lex.c
--- a/usr.bin/mail/lex.c        Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/lex.c        Tue Jan 12 14:45:31 2010 +0000
@@ -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:
diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/list.c
--- a/usr.bin/mail/list.c       Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/list.c       Tue Jan 12 14:45:31 2010 +0000
@@ -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);
diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/main.c
--- a/usr.bin/mail/main.c       Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/main.c       Tue Jan 12 14:45:31 2010 +0000
@@ -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.");
diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/names.c
--- a/usr.bin/mail/names.c      Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/names.c      Tue Jan 12 14:45:31 2010 +0000
@@ -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
diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/strings.c
--- a/usr.bin/mail/strings.c    Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/strings.c    Tue Jan 12 14:45:31 2010 +0000
@@ -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;
        }
diff -r a70cb1ed8e5f -r 5da1e96bfd3c usr.bin/mail/temp.c
--- a/usr.bin/mail/temp.c       Tue Jan 12 14:44:24 2010 +0000
+++ b/usr.bin/mail/temp.c       Tue Jan 12 14:45:31 2010 +0000
@@ -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) {



Home | Main Index | Thread Index | Old Index