error message cleanup

- 1 -> EXIT_FAILURE
- fprintf(stderr, -> warnx(
- better warning messages
This commit is contained in:
christos 2010-01-12 14:45:31 +00:00
parent b8afdde726
commit d449716afd
7 changed files with 32 additions and 31 deletions

View File

@ -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 @@ makemessage(FILE *f, int omsgCount, int nmsgCount)
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 @@ setinput(const struct message *mp)
(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 @@ expand(const char *name)
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 @@ expand(const char *name)
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 @@ expand(const char *name)
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);

View File

@ -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 @@ setfile(const char *name)
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 @@ setfile(const char *name)
"%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 @@ execute(char linebuf[], enum execute_contxt_e contxt)
break;
default:
errx(1, "Unknown argtype");
errx(EXIT_FAILURE, "Unknown argtype");
}
out:

View File

@ -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 @@ static void
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);

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#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 @@ main(int argc, char *argv[])
* 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.");

View File

@ -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 @@ unpack(struct name *np)
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

View File

@ -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 @@ salloc(size_t size)
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;
}

View File

@ -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 @@ tinit(void)
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) {