From 33c506bfed3ead4cc96819ce600895082c214755 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Thu, 31 Jul 2003 21:48:04 +0000 Subject: various cleanups; david says results are same --- src/regress/lib/libc/alloca/alloca.c | 4 +-- src/regress/lib/libc/atexit/atexit_test.c | 22 ++++++++-------- src/regress/lib/libc/db/dbtest.c | 10 +++----- src/regress/lib/libc/ieeefp/except/except.c | 16 ++++++------ src/regress/lib/libc/ieeefp/inf/inf.c | 4 +-- src/regress/lib/libc/ieeefp/round/round.c | 4 +-- .../lib/libc/malloc/malloc0test/malloc0test.c | 6 ++--- .../lib/libc/malloc/malloc_errno/malloc_errno.c | 4 +-- src/regress/lib/libc/regex/debug.c | 6 ++--- src/regress/lib/libc/regex/main.c | 29 +++++++++++----------- src/regress/lib/libc/regex/split.c | 10 +++----- src/regress/lib/libc/setjmp/jmptest.c | 11 +++----- src/regress/lib/libc/sigreturn/sigret.c | 8 +++--- 13 files changed, 64 insertions(+), 70 deletions(-) diff --git a/src/regress/lib/libc/alloca/alloca.c b/src/regress/lib/libc/alloca/alloca.c index c8a6b6b40c..1c26429293 100644 --- a/src/regress/lib/libc/alloca/alloca.c +++ b/src/regress/lib/libc/alloca/alloca.c @@ -1,11 +1,11 @@ -/* $OpenBSD: alloca.c,v 1.3 2003/07/31 03:23:41 mickey Exp $ */ +/* $OpenBSD: alloca.c,v 1.4 2003/07/31 21:48:02 deraadt Exp $ */ /* Written by Michael Shalayeff, 2003, Public Domain. */ #include int -main() +main(int argc, char *argv[]) { char *q, *p; diff --git a/src/regress/lib/libc/atexit/atexit_test.c b/src/regress/lib/libc/atexit/atexit_test.c index df316e3372..c30b9dff77 100644 --- a/src/regress/lib/libc/atexit/atexit_test.c +++ b/src/regress/lib/libc/atexit/atexit_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atexit_test.c,v 1.3 2002/10/21 20:40:50 mickey Exp $ */ +/* $OpenBSD: atexit_test.c,v 1.4 2003/07/31 21:48:02 deraadt Exp $ */ /* * Copyright (c) 2002 Daniel Hartmeier @@ -39,11 +39,11 @@ #include #include "stdlib/atexit.h" -void handle_first(); -void handle_middle(); -void handle_last(); -void handle_invalid(); -void handle_cleanup(); +void handle_first(void); +void handle_middle(void); +void handle_last(void); +void handle_invalid(void); +void handle_cleanup(void); void handle_signal(int); static int counter; @@ -96,31 +96,31 @@ main(int argc, char *argv[]) } void -handle_first() +handle_first(void) { fprintf(stderr, "handle_first() counter == %i\n", counter); } void -handle_middle() +handle_middle(void) { counter++; } void -handle_last() +handle_last(void) { fprintf(stderr, "handle_last() counter == %i\n", counter); } void -handle_cleanup() +handle_cleanup(void) { fprintf(stderr, "handle_cleanup()\n"); } void -handle_invalid() +handle_invalid(void) { fprintf(stderr, "handle_invalid() THIS SHOULD HAVE SEGFAULTED INSTEAD!\n"); } diff --git a/src/regress/lib/libc/db/dbtest.c b/src/regress/lib/libc/db/dbtest.c index 0cefba3e1f..8eda40d6b3 100644 --- a/src/regress/lib/libc/db/dbtest.c +++ b/src/regress/lib/libc/db/dbtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dbtest.c,v 1.10 2003/06/02 19:38:25 millert Exp $ */ +/* $OpenBSD: dbtest.c,v 1.11 2003/07/31 21:48:02 deraadt Exp $ */ /* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */ /*- @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94"; #else -static char rcsid[] = "$OpenBSD: dbtest.c,v 1.10 2003/06/02 19:38:25 millert Exp $"; +static char rcsid[] = "$OpenBSD: dbtest.c,v 1.11 2003/07/31 21:48:02 deraadt Exp $"; #endif #endif /* not lint */ @@ -88,9 +88,7 @@ DB *XXdbp; /* Global for gdb. */ int XXlineno; /* Fast breakpoint for gdb. */ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { extern int optind; extern char *optarg; @@ -158,7 +156,7 @@ main(argc, argv) p = getenv("TMPDIR"); if (p == NULL) p = "/var/tmp"; - (void)sprintf(buf, "%s/__dbtest", p); + (void)snprintf(buf, sizeof buf, "%s/__dbtest", p); fname = buf; (void)unlink(buf); } else if (!sflag) diff --git a/src/regress/lib/libc/ieeefp/except/except.c b/src/regress/lib/libc/ieeefp/except/except.c index 6b65e8f3c4..7ab8fc4cb2 100644 --- a/src/regress/lib/libc/ieeefp/except/except.c +++ b/src/regress/lib/libc/ieeefp/except/except.c @@ -1,4 +1,4 @@ -/* $OpenBSD: except.c,v 1.3 2001/01/29 02:05:42 niklas Exp $ */ +/* $OpenBSD: except.c,v 1.4 2003/07/31 21:48:03 deraadt Exp $ */ #include #include @@ -6,7 +6,6 @@ #include #include -void sigfpe(); volatile sig_atomic_t signal_cought; static volatile const double one = 1.0; @@ -14,8 +13,14 @@ static volatile const double zero = 0.0; static volatile const double huge = DBL_MAX; static volatile const double tiny = DBL_MIN; +static void +sigfpe(int signo) +{ + signal_cought = 1; +} + int -main() +main(int argc, char *argv[]) { volatile double x; @@ -83,8 +88,3 @@ main() exit(0); } -void -sigfpe() -{ - signal_cought = 1; -} diff --git a/src/regress/lib/libc/ieeefp/inf/inf.c b/src/regress/lib/libc/ieeefp/inf/inf.c index b6116b0df1..a1956145a6 100644 --- a/src/regress/lib/libc/ieeefp/inf/inf.c +++ b/src/regress/lib/libc/ieeefp/inf/inf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inf.c,v 1.2 2002/02/18 11:24:13 art Exp $ */ +/* $OpenBSD: inf.c,v 1.3 2003/07/31 21:48:03 deraadt Exp $ */ /* * Peter Valchev Public Domain, 2002. @@ -7,7 +7,7 @@ #include int -main() +main(int argc, char *argv[]) { if (isinf(HUGE_VAL)) return 0; diff --git a/src/regress/lib/libc/ieeefp/round/round.c b/src/regress/lib/libc/ieeefp/round/round.c index 086c4fdf10..807941ea56 100644 --- a/src/regress/lib/libc/ieeefp/round/round.c +++ b/src/regress/lib/libc/ieeefp/round/round.c @@ -1,4 +1,4 @@ -/* $OpenBSD: round.c,v 1.2 2001/01/29 02:05:43 niklas Exp $ */ +/* $OpenBSD: round.c,v 1.3 2003/07/31 21:48:03 deraadt Exp $ */ /* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */ /* @@ -12,7 +12,7 @@ #include int -main() +main(int argc, char *argv[]) { /* * This test would be better if it actually performed some diff --git a/src/regress/lib/libc/malloc/malloc0test/malloc0test.c b/src/regress/lib/libc/malloc/malloc0test/malloc0test.c index 39c3fd2e64..910b466bd4 100644 --- a/src/regress/lib/libc/malloc/malloc0test/malloc0test.c +++ b/src/regress/lib/libc/malloc/malloc0test/malloc0test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc0test.c,v 1.1 2003/07/15 10:09:37 otto Exp $ */ +/* $OpenBSD: malloc0test.c,v 1.2 2003/07/31 21:48:03 deraadt Exp $ */ /* * Public domain. 2001, Theo de Raadt */ @@ -14,14 +14,14 @@ volatile sig_atomic_t got; jmp_buf jmp; -void +static void catch(int signo) { got++; longjmp(jmp, 1); } -int +static int test(char *p, int size) { signal(SIGSEGV, catch); diff --git a/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c b/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c index 61d85e5d41..1232dd660d 100644 --- a/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c +++ b/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc_errno.c,v 1.1 2003/07/15 10:06:31 otto Exp $ */ +/* $OpenBSD: malloc_errno.c,v 1.2 2003/07/31 21:48:03 deraadt Exp $ */ /* * Public domain. 2003, Otto Moerbeek */ @@ -30,7 +30,7 @@ testerrno(size_t sz) * correctly. */ int -main() +main(int argc, char *argv[]) { size_t i; diff --git a/src/regress/lib/libc/regex/debug.c b/src/regress/lib/libc/regex/debug.c index 7834e970c7..11129e7249 100644 --- a/src/regress/lib/libc/regex/debug.c +++ b/src/regress/lib/libc/regex/debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.c,v 1.3 2001/01/29 02:05:43 niklas Exp $ */ +/* $OpenBSD: debug.c,v 1.4 2003/07/31 21:48:03 deraadt Exp $ */ /* $NetBSD: debug.c,v 1.2 1995/04/20 22:39:42 cgd Exp $ */ #include @@ -238,8 +238,8 @@ int ch; static char buf[10]; if (isprint(ch) || ch == ' ') - sprintf(buf, "%c", ch); + snprintf(buf, sizeof buf, "%c", ch); else - sprintf(buf, "\\%o", ch); + snprintf(buf, sizeof buf, "\\%o", ch); return(buf); } diff --git a/src/regress/lib/libc/regex/main.c b/src/regress/lib/libc/regex/main.c index 6e63ffc235..02f4bd7cf2 100644 --- a/src/regress/lib/libc/regex/main.c +++ b/src/regress/lib/libc/regex/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.3 1997/01/15 23:41:07 millert Exp $ */ +/* $OpenBSD: main.c,v 1.4 2003/07/31 21:48:03 deraadt Exp $ */ /* $NetBSD: main.c,v 1.2 1995/04/20 22:39:51 cgd Exp $ */ #include @@ -22,16 +22,15 @@ regoff_t startoff = 0; regoff_t endoff = 0; -extern int split(); -extern void regprint(); +extern int split(char *, char *[], int, char *); +extern void regprint(regex_t *, FILE *); /* - main - do the simple case, hand off to regress() for regression */ int -main(argc, argv) -int argc; -char *argv[]; +main(int argc, char *argv[]) + { regex_t re; # define NS 10 @@ -431,8 +430,9 @@ char *should; (sub.rm_so != -1 && sub.rm_eo == -1) || (sub.rm_so != -1 && sub.rm_so < 0) || (sub.rm_eo != -1 && sub.rm_eo < 0) ) { - sprintf(grump, "start %ld end %ld", (long)sub.rm_so, - (long)sub.rm_eo); + snprintf(grump, sizeof grump, + "start %ld end %ld", (long)sub.rm_so, + (long)sub.rm_eo); return(grump); } @@ -444,8 +444,9 @@ char *should; /* check for in range */ if (sub.rm_eo > strlen(str)) { - sprintf(grump, "start %ld end %ld, past end of string", - (long)sub.rm_so, (long)sub.rm_eo); + snprintf(grump, sizeof grump, + "start %ld end %ld, past end of string", + (long)sub.rm_so, (long)sub.rm_eo); return(grump); } @@ -455,13 +456,13 @@ char *should; /* check for not supposed to match */ if (should == NULL) { - sprintf(grump, "matched `%.*s'", len, p); + snprintf(grump, sizeof grump, "matched `%.*s'", len, p); return(grump); } /* check for wrong match */ if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) { - sprintf(grump, "matched `%.*s' instead", len, p); + snprintf(grump, sizeof grump, "matched `%.*s' instead", len, p); return(grump); } if (shlen > 0) @@ -474,7 +475,7 @@ char *should; if (shlen == 0) shlen = 1; /* force check for end-of-string */ if (strncmp(p, at, shlen) != 0) { - sprintf(grump, "matched null at `%.20s'", p); + snprintf(grump, sizeof grump, "matched null at `%.20s'", p); return(grump); } return(NULL); @@ -507,7 +508,7 @@ char *name; static char efbuf[100]; regex_t re; - sprintf(efbuf, "REG_%s", name); + snprintf(efbuf, sizeof efbuf, "REG_%s", name); assert(strlen(efbuf) < sizeof(efbuf)); re.re_endp = efbuf; (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf)); diff --git a/src/regress/lib/libc/regex/split.c b/src/regress/lib/libc/regex/split.c index 52cb6c681e..1e17a55b89 100644 --- a/src/regress/lib/libc/regex/split.c +++ b/src/regress/lib/libc/regex/split.c @@ -1,19 +1,17 @@ -/* $OpenBSD: split.c,v 1.2 2001/01/29 02:05:44 niklas Exp $ */ +/* $OpenBSD: split.c,v 1.3 2003/07/31 21:48:03 deraadt Exp $ */ /* $NetBSD: split.c,v 1.2 1995/04/20 22:39:57 cgd Exp $ */ #include #include +int split(char *string, char *fields[], int nfields, char *sep); + /* - split - divide a string into fields, like awk split() = int split(char *string, char *fields[], int nfields, char *sep); */ int /* number of fields, including overflow */ -split(string, fields, nfields, sep) -char *string; -char *fields[]; /* list is not NULL-terminated */ -int nfields; /* number of entries available in fields[] */ -char *sep; /* "" white, "c" single char, "ab" [ab]+ */ +split(char *string, char *fields[], int nfields, char *sep) { register char *p = string; register char c; /* latest character */ diff --git a/src/regress/lib/libc/setjmp/jmptest.c b/src/regress/lib/libc/setjmp/jmptest.c index de6e70d9f6..86b0e6ae93 100644 --- a/src/regress/lib/libc/setjmp/jmptest.c +++ b/src/regress/lib/libc/setjmp/jmptest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jmptest.c,v 1.5 2001/11/11 23:26:35 deraadt Exp $ */ +/* $OpenBSD: jmptest.c,v 1.6 2003/07/31 21:48:03 deraadt Exp $ */ /* $NetBSD: jmptest.c,v 1.2 1995/01/01 20:55:35 jtc Exp $ */ /* @@ -64,9 +64,8 @@ int expectsignal; -void -aborthandler(signo) - int signo; +static void +aborthandler(int signo) { if (expectsignal) @@ -78,9 +77,7 @@ aborthandler(signo) } int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { struct sigaction sa; BUF jb; diff --git a/src/regress/lib/libc/sigreturn/sigret.c b/src/regress/lib/libc/sigreturn/sigret.c index 416869007a..72945fa503 100644 --- a/src/regress/lib/libc/sigreturn/sigret.c +++ b/src/regress/lib/libc/sigreturn/sigret.c @@ -1,5 +1,5 @@ /* - * $OpenBSD: sigret.c,v 1.4 2002/04/30 01:59:47 deraadt Exp $ + * $OpenBSD: sigret.c,v 1.5 2003/07/31 21:48:04 deraadt Exp $ * * Public Domain * @@ -64,13 +64,13 @@ usage(const char * err, ...) exit(1); } -void +static void indirect_return(struct sigcontext * scp) { sigreturn(scp); } -void +static void sig_handler(int sig, siginfo_t *blah, void *x) { struct sigcontext * scp = x; @@ -90,7 +90,7 @@ sig_handler(int sig, siginfo_t *blah, void *x) } } -void +static void test2(char *fmt) { char *ofmt = fmt; -- cgit v1.2.3-55-g6feb