From 00b8e31689c6400d8ad915067f021b8e246df989 Mon Sep 17 00:00:00 2001 From: jsm Date: Sun, 25 Mar 2001 20:43:58 +0000 Subject: Make mostly gcc -W clean, and other cleanup: Use const. Add __noreturn__ attributes. Add a __format__ attribute. Add __unused__ attributes. Use symbolic constants for open() and lseek(). Declare types of all function parameters; convert some function definitions to ISO C form. Ensure standard file descriptors are open on startup. Check for errors writing output of makedefs. Avoid duplicate definitions of variables. --- hack/makedefs.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'hack/makedefs.c') diff --git a/hack/makedefs.c b/hack/makedefs.c index 3aa621c6..fd19fa84 100644 --- a/hack/makedefs.c +++ b/hack/makedefs.c @@ -1,15 +1,16 @@ -/* $NetBSD: makedefs.c,v 1.6 2000/07/31 11:35:03 simonb Exp $ */ +/* $NetBSD: makedefs.c,v 1.7 2001/03/25 20:44:04 jsm Exp $ */ /* * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ #ifndef lint -static char rcsid[] = - "$NetBSD: makedefs.c,v 1.6 2000/07/31 11:35:03 simonb Exp $"; +static const char rcsid[] = + "$NetBSD: makedefs.c,v 1.7 2001/03/25 20:44:04 jsm Exp $"; #endif /* not lint */ #include +#include #include #include #include @@ -23,7 +24,7 @@ char string[STRSZ]; static void readline(void); static char nextchar(void); -static int skipuntil(char *); +static int skipuntil(const char *); static int getentry(void); static void capitalize(char *); static int letter(int); @@ -43,7 +44,7 @@ main(argc, argv) (void) fprintf(stderr, "usage: makedefs file\n"); exit(1); } - if ((fd = open(argv[1], 0)) < 0) { + if ((fd = open(argv[1], O_RDONLY)) < 0) { perror(argv[1]); exit(1); } @@ -74,6 +75,11 @@ main(argc, argv) printf("#define LAST_GEM (JADE+1)\n"); printf("#define LAST_RING %d\n", propct); printf("#define NROFOBJECTS %d\n", i - 1); + fflush(stdout); + if (ferror(stdout)) { + perror("standard output"); + exit(1); + } exit(0); } @@ -105,9 +111,10 @@ nextchar() static int skipuntil(s) - char *s; + const char *s; { - char *sp0, *sp1; + const char *sp0; + char *sp1; loop: while (*s != nextchar()) if (eof) { -- cgit v1.2.3