diff options
author | Moritz Jodeit <moritz@cvs.openbsd.org> | 2006-03-08 07:18:52 +0000 |
---|---|---|
committer | Moritz Jodeit <moritz@cvs.openbsd.org> | 2006-03-08 07:18:52 +0000 |
commit | b9090b32b151b4c468b823b982594e83a0921fe9 (patch) | |
tree | 5447bc74af39f544df5645df816e1a2827336009 /usr.bin/xlint | |
parent | 4601e2a18312aa0a1106f5d2a3628d51c2acf4c0 (diff) |
some cleanup including:
o typos in comments
o missing #include
o remove pointless nomem() func
o unused variables
o more use of asprintf(3)
ok deraadt@
Diffstat (limited to 'usr.bin/xlint')
-rw-r--r-- | usr.bin/xlint/lint1/decl.c | 6 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/err.c | 5 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/externs.h | 3 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/lint.h | 4 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/lint1.h | 4 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/mem.c | 18 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/mem1.c | 5 | ||||
-rw-r--r-- | usr.bin/xlint/xlint/xlint.c | 38 |
8 files changed, 34 insertions, 49 deletions
diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index ff017b9deb0..449baa6b2b7 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: decl.c,v 1.19 2005/12/18 19:21:02 cloder Exp $ */ +/* $OpenBSD: decl.c,v 1.20 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: decl.c,v 1.19 2005/12/18 19:21:02 cloder Exp $"; +static char rcsid[] = "$OpenBSD: decl.c,v 1.20 2006/03/08 07:18:51 moritz Exp $"; #endif #include <sys/param.h> @@ -48,7 +48,7 @@ const char *unnamed = "<unnamed>"; /* contains various information and classification on types */ ttab_t ttab[NTSPEC]; -/* shared type structures for arithmtic types and void */ +/* shared type structures for arithmetic types and void */ static type_t *typetab; /* value of next enumerator during declaration of enum types */ diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c index 33e5ebb17de..fc464fc6205 100644 --- a/usr.bin/xlint/lint1/err.c +++ b/usr.bin/xlint/lint1/err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err.c,v 1.18 2006/01/16 22:16:14 espie Exp $ */ +/* $OpenBSD: err.c,v 1.19 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: err.c,v 1.8 1995/10/02 17:37:00 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: err.c,v 1.18 2006/01/16 22:16:14 espie Exp $"; +static char rcsid[] = "$OpenBSD: err.c,v 1.19 2006/03/08 07:18:51 moritz Exp $"; #endif /* number of errors found */ @@ -44,6 +44,7 @@ int sytxerr; #include <stdlib.h> #include <stdarg.h> +#include <err.h> #include "lint1.h" diff --git a/usr.bin/xlint/lint1/externs.h b/usr.bin/xlint/lint1/externs.h index afbdbb58fd9..a8834ab559f 100644 --- a/usr.bin/xlint/lint1/externs.h +++ b/usr.bin/xlint/lint1/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.3 2002/02/16 21:27:59 millert Exp $ */ +/* $OpenBSD: externs.h,v 1.4 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: externs.h,v 1.2 1995/07/03 21:24:06 cgd Exp $ */ /* @@ -39,7 +39,6 @@ extern void *xmalloc(size_t); extern void *xcalloc(size_t, size_t); extern void *xrealloc(void *, size_t); extern char *xstrdup(const char *); -extern void nomem(void); /* * emit.c diff --git a/usr.bin/xlint/lint1/lint.h b/usr.bin/xlint/lint1/lint.h index 45c61902477..ff2589e1777 100644 --- a/usr.bin/xlint/lint1/lint.h +++ b/usr.bin/xlint/lint1/lint.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lint.h,v 1.3 2005/12/10 18:51:54 martin Exp $ */ +/* $OpenBSD: lint.h,v 1.4 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: lint.h,v 1.2 1995/07/03 21:24:18 cgd Exp $ */ /* @@ -39,7 +39,7 @@ #include "param.h" /* - * Type specifiers, used in type structures (type_t) and otherwere. + * Type specifiers, used in type structures (type_t) and elsewhere. */ typedef enum { NOTSPEC, diff --git a/usr.bin/xlint/lint1/lint1.h b/usr.bin/xlint/lint1/lint1.h index 758c25cc93a..d6ef4fb9dd7 100644 --- a/usr.bin/xlint/lint1/lint1.h +++ b/usr.bin/xlint/lint1/lint1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lint1.h,v 1.11 2005/12/17 21:08:27 cloder Exp $ */ +/* $OpenBSD: lint1.h,v 1.12 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: lint1.h,v 1.6 1995/10/02 17:31:41 jpo Exp $ */ /* @@ -90,7 +90,7 @@ typedef struct { * Structures of type str_t uniqely identify structures. This can't * be done in structures of type type_t, because these are copied * if they must be modified. So it would not be possible to check - * if to structures are identical by comparing the pointers to + * if two structures are identical by comparing the pointers to * the type structures. * * The typename is used if the structure is unnamed to identify diff --git a/usr.bin/xlint/lint1/mem.c b/usr.bin/xlint/lint1/mem.c index e91772d85d7..0fce3f26362 100644 --- a/usr.bin/xlint/lint1/mem.c +++ b/usr.bin/xlint/lint1/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.3 2005/11/19 03:35:27 cloder Exp $ */ +/* $OpenBSD: mem.c,v 1.4 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: mem.c,v 1.2 1995/07/03 21:24:24 cgd Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: mem.c,v 1.3 2005/11/19 03:35:27 cloder Exp $"; +static char rcsid[] = "$OpenBSD: mem.c,v 1.4 2006/03/08 07:18:51 moritz Exp $"; #endif #include <stdlib.h> @@ -48,7 +48,7 @@ xmalloc(size_t s) void *p; if ((p = malloc(s)) == NULL) - nomem(); + err(1, NULL); return (p); } @@ -58,7 +58,7 @@ xcalloc(size_t n, size_t s) void *p; if ((p = calloc(n, s)) == NULL) - nomem(); + err(1, NULL); return (p); } @@ -66,7 +66,7 @@ void * xrealloc(void *p, size_t s) { if ((p = realloc(p, s)) == NULL) - nomem(); + err(1, NULL); return (p); } @@ -76,12 +76,6 @@ xstrdup(const char *s) char *s2; if ((s2 = strdup(s)) == NULL) - nomem(); + err(1, NULL); return (s2); } - -void -nomem(void) -{ - errx(1, "virtual memory exhausted"); -} diff --git a/usr.bin/xlint/lint1/mem1.c b/usr.bin/xlint/lint1/mem1.c index 9a67ac76e35..d31bdabfb9d 100644 --- a/usr.bin/xlint/lint1/mem1.c +++ b/usr.bin/xlint/lint1/mem1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem1.c,v 1.9 2005/11/29 20:09:39 cloder Exp $ */ +/* $OpenBSD: mem1.c,v 1.10 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: mem1.c,v 1.2 1995/07/03 21:24:25 cgd Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: mem1.c,v 1.9 2005/11/29 20:09:39 cloder Exp $"; +static char rcsid[] = "$OpenBSD: mem1.c,v 1.10 2006/03/08 07:18:51 moritz Exp $"; #endif #include <sys/types.h> @@ -166,7 +166,6 @@ static mbl_t * xnewblk(void) { mbl_t *mb; - int prot, flags; mb = xmalloc(sizeof (mbl_t)); mb->blk = xmalloc(mblklen); diff --git a/usr.bin/xlint/xlint/xlint.c b/usr.bin/xlint/xlint/xlint.c index cae7e59384a..28a3269c4bb 100644 --- a/usr.bin/xlint/xlint/xlint.c +++ b/usr.bin/xlint/xlint/xlint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xlint.c,v 1.26 2006/03/07 08:24:55 moritz Exp $ */ +/* $OpenBSD: xlint.c,v 1.27 2006/03/08 07:18:51 moritz Exp $ */ /* $NetBSD: xlint.c,v 1.3 1995/10/23 14:29:30 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: xlint.c,v 1.26 2006/03/07 08:24:55 moritz Exp $"; +static char rcsid[] = "$OpenBSD: xlint.c,v 1.27 2006/03/08 07:18:51 moritz Exp $"; #endif #include <sys/param.h> @@ -110,7 +110,6 @@ static int first = 1; */ static const char *currfn; - static void appstrg(char ***, char *); static void appcstrg(char ***, const char *); static void applst(char ***, char *const *); @@ -279,7 +278,7 @@ main(int argc, char *argv[]) { int c; char flgbuf[3], *tmp, *s; - size_t len, l; + size_t len; struct utsname un; if ((tmp = getenv("TMPDIR")) == NULL || (len = strlen(tmp)) == 0) { @@ -291,9 +290,8 @@ main(int argc, char *argv[]) tmpdir = s; } - len = strlen(tmpdir) + sizeof ("lint0.XXXXXXXXXX"); - cppout = xmalloc(len); - (void)snprintf(cppout, len, "%slint0.XXXXXXXXXX", tmpdir); + if (asprintf(&cppout, "%slint0.XXXXXXXXXX", tmpdir) == -1) + err(1, NULL); if (mktemp(cppout) == NULL) { warn("can't make temp"); terminate(-1); @@ -427,9 +425,8 @@ main(int argc, char *argv[]) usage(); Cflag = 1; appstrg(&l2flags, concat2("-C", optarg)); - l = sizeof ("llib-l.ln") + strlen(optarg); - p2out = xmalloc(l); - (void)snprintf(p2out, l, "llib-l%s.ln", optarg); + if (asprintf(&p2out, "llib-l%s.ln", optarg) == -1) + err(1, NULL); freelst(&deflibs); break; @@ -546,9 +543,8 @@ fname(const char *name) bn == suff ? strlen(bn) : (suff - 1) - bn, bn); (void)strlcat(ofn, ".ln", len); } else { - len = strlen(tmpdir) + sizeof ("lint1.XXXXXXXXXX"); - ofn = xmalloc(len); - (void)snprintf(ofn, len, "%slint1.XXXXXXXXXX", tmpdir); + if (asprintf(&ofn, "%slint1.XXXXXXXXXX", tmpdir) == -1) + err(1, NULL); if (mktemp(ofn) == NULL) { warn("can't make temp"); terminate(-1); @@ -561,9 +557,8 @@ fname(const char *name) /* run cpp */ - len = strlen(PATH_LIBEXEC) + sizeof ("/cpp"); - path = xmalloc(len); - (void)snprintf(path, len, "%s/cpp", PATH_LIBEXEC); + if (asprintf(&path, "%s/cpp", PATH_LIBEXEC) == -1) + err(1, NULL); appcstrg(&args, path); applst(&args, cppflags); @@ -579,9 +574,8 @@ fname(const char *name) /* run lint1 */ - len = strlen(PATH_LIBEXEC) + sizeof ("/lint1"); - path = xmalloc(len); - (void)snprintf(path, len, "%s/lint1", PATH_LIBEXEC); + if (asprintf(&path, "%s/lint1", PATH_LIBEXEC) == -1) + err(1, NULL); appcstrg(&args, path); applst(&args, l1flags); @@ -700,13 +694,11 @@ static void lint2() { char *path, **args; - size_t len; args = xcalloc(1, sizeof (char *)); - len = strlen(PATH_LIBEXEC) + sizeof ("/lint2"); - path = xmalloc(len); - (void)snprintf(path, len, "%s/lint2", PATH_LIBEXEC); + if (asprintf(&path, "%s/lint2", PATH_LIBEXEC) == -1) + err(1, NULL); appcstrg(&args, path); applst(&args, l2flags); |