diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-01-20 10:26:17 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-01-20 10:26:17 +0000 |
commit | 429dafba6d12db9382edb88285bbc77ccffa5613 (patch) | |
tree | 33772f2a6fb00bd4f9ea1afd3734114ddad9da38 /usr.bin | |
parent | e8dd6f5a53004089bc93d9d41fd25f679cee8e17 (diff) |
Split error() into error() and warning() so error() can be marked __dead to
appease gcc.
ok procter@ deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sed/compile.c | 10 | ||||
-rw-r--r-- | usr.bin/sed/defs.h | 3 | ||||
-rw-r--r-- | usr.bin/sed/extern.h | 5 | ||||
-rw-r--r-- | usr.bin/sed/main.c | 9 | ||||
-rw-r--r-- | usr.bin/sed/misc.c | 21 | ||||
-rw-r--r-- | usr.bin/sed/process.c | 3 |
6 files changed, 29 insertions, 22 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c index b2f7d36995b..2d5007eee3b 100644 --- a/usr.bin/sed/compile.c +++ b/usr.bin/sed/compile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compile.c,v 1.40 2015/10/26 22:24:44 jca Exp $ */ +/* $OpenBSD: compile.c,v 1.41 2017/01/20 10:26:16 krw Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -520,14 +520,12 @@ compile_subst(char *p, struct s_subst *s) } else if (*p == '\n') { error(COMPILE, "unescaped newline inside substitute pattern"); - /* NOTREACHED */ } *sp++ = *p; } size += sp - op; } while ((p = cu_fgets(&lbuf, &bufsize))); error(COMPILE, "unterminated substitute in regular expression"); - /* NOTREACHED */ } /* @@ -578,7 +576,7 @@ compile_flags(char *p, struct s_subst *s) p++; #ifdef HISTORIC_PRACTICE if (*p != ' ') { - error(WARNING, "space missing before w wfile"); + warning("space missing before w wfile"); return (p); } #endif @@ -750,7 +748,7 @@ duptoeol(char *s, char *ctype, char **semi) *s = '\0'; } if (ws) - error(WARNING, "whitespace after %s", ctype); + warning("whitespace after %s", ctype); len = s - start + 1; if (semi) *semi = s; @@ -854,7 +852,7 @@ uselabel(void) for (lh = labels[i]; lh != NULL; lh = next) { next = lh->lh_next; if (!lh->lh_ref) - error(WARNING, "unused label '%s'", + warning("unused label '%s'", lh->lh_cmd->t); free(lh); } diff --git a/usr.bin/sed/defs.h b/usr.bin/sed/defs.h index f7089ce34be..4864d620399 100644 --- a/usr.bin/sed/defs.h +++ b/usr.bin/sed/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.7 2015/10/26 22:24:44 jca Exp $ */ +/* $OpenBSD: defs.h,v 1.8 2017/01/20 10:26:16 krw Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993 @@ -136,7 +136,6 @@ typedef struct { /* * Error severity codes: */ -#define WARNING 0 /* Just print the warning */ #define FATAL 1 /* Exit immediately with 1 */ #define COMPILE 2 /* Print error, count and finish script */ diff --git a/usr.bin/sed/extern.h b/usr.bin/sed/extern.h index ea51bdba9ea..ae3cc6963d0 100644 --- a/usr.bin/sed/extern.h +++ b/usr.bin/sed/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.11 2015/10/26 14:08:47 mmcc Exp $ */ +/* $OpenBSD: extern.h,v 1.12 2017/01/20 10:26:16 krw Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993 @@ -48,7 +48,8 @@ void cfclose(struct s_command *, struct s_command *); void compile(void); void cspace(SPACE *, const char *, size_t, enum e_spflag); char *cu_fgets(char **, size_t *); -void error(int, const char *, ...); +__dead void error(int, const char *, ...); +void warning(const char *, ...); int mf_fgets(SPACE *, enum e_spflag); int lastline(void); void process(void); diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index cddafbbd4f5..bd69dc85e6e 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.33 2016/07/14 08:31:18 semarie Exp $ */ +/* $OpenBSD: main.c,v 1.34 2017/01/20 10:26:16 krw Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -285,7 +285,8 @@ again: } } } - /* NOTREACHED */ + + return (NULL); } /* @@ -329,7 +330,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) fclose(infile); if (*oldfname != '\0') { if (rename(fname, oldfname) != 0) { - error(WARNING, "rename()"); + warning("rename()"); unlink(tmpfname); exit(1); } @@ -389,7 +390,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) outfname = "stdout"; } if ((infile = fopen(fname, "r")) == NULL) { - error(WARNING, "%s", strerror(errno)); + warning("%s", strerror(errno)); rval = 1; continue; } diff --git a/usr.bin/sed/misc.c b/usr.bin/sed/misc.c index e0611b8c731..99ff1fda0d6 100644 --- a/usr.bin/sed/misc.c +++ b/usr.bin/sed/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.11 2015/10/26 14:08:47 mmcc Exp $ */ +/* $OpenBSD: misc.c,v 1.12 2017/01/20 10:26:16 krw Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -101,7 +101,7 @@ strregerror(int errcode, regex_t *preg) /* * Error reporting function */ -void +__dead void error(int severity, const char *fmt, ...) { va_list ap; @@ -109,15 +109,24 @@ error(int severity, const char *fmt, ...) va_start(ap, fmt); (void)fprintf(stderr, "sed: "); switch (severity) { - case WARNING: case COMPILE: (void)fprintf(stderr, "%lu: %s: ", linenum, fname); } (void)vfprintf(stderr, fmt, ap); va_end(ap); (void)fprintf(stderr, "\n"); - if (severity == WARNING) - return; exit(1); - /* NOTREACHED */ +} + +void +warning(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + (void)fprintf(stderr, "sed: "); + (void)fprintf(stderr, "%lu: %s: ", linenum, fname); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + (void)fprintf(stderr, "\n"); } diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index 16823ece1f3..81bf2ad322b 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process.c,v 1.29 2016/10/11 19:27:39 martijn Exp $ */ +/* $OpenBSD: process.c,v 1.30 2017/01/20 10:26:16 krw Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -539,7 +539,6 @@ regexec_e(regex_t *preg, const char *string, int eflags, return (0); } error(FATAL, "RE error: %s", strregerror(eval, defpreg)); - /* NOTREACHED */ } /* |