Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Sep 2001 21:54:28 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Mark Murray <mark@grondar.za>
Cc:        <audit@FreeBSD.ORG>
Subject:   Re: WARNS=2 cleanup for lex and yacc
Message-ID:  <20010914211123.O18340-100000@delplex.bde.org>
In-Reply-To: <200109121934.f8CJY6u89490@grimreaper.grondar.za>

next in thread | previous in thread | raw e-mail | index | archive | help

On Wed, 12 Sep 2001, Mark Murray wrote:

> Please review

> Index: lex/Makefile
> ...

Lex is gnu flex so it shouldn't be maintained by FreeBSD.

> ...
> Index: yacc/Makefile
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/Makefile,v
> retrieving revision 1.10
> diff -u -d -r1.10 Makefile
> --- yacc/Makefile	7 Apr 2001 11:21:26 -0000	1.10
> +++ yacc/Makefile	12 Sep 2001 14:20:53 -0000
> @@ -8,5 +8,6 @@
>  MAN=	yacc.1 yyfix.1
>  LINKS=	${BINDIR}/yacc ${BINDIR}/byacc
>  MLINKS=	yacc.1 byacc.1
> +WARNS?=	2

Don't blindly add to the end of sorted lists.  Definitions in Makefiles
are mostly sorted in the order in which they are used in the build, and
this Makefile was no exception.  (WARNS goes after CFLAGS which goes
after SRCS.)

> Index: yacc/defs.h
> ...
> Index: yacc/error.c
> ...

OK

> Index: yacc/lalr.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/lalr.c,v
> retrieving revision 1.7
> diff -u -d -r1.7 lalr.c
> --- yacc/lalr.c	28 Aug 1999 01:07:59 -0000	1.7
> +++ yacc/lalr.c	12 Sep 2001 14:26:19 -0000
> @@ -415,7 +415,7 @@
>    register shifts *sp;
>    register int length;
>    register int nedges;
> -  register int done;
> +  register int isdone;

Might shadow something in <ctypes.h> someday, though not currently invalid
since <ctypes.h> is not included.  Maybe rename it to done1.

> ...
> Index: yacc/lr0.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/lr0.c,v
> retrieving revision 1.6
> diff -u -d -r1.6 lr0.c
> --- yacc/lr0.c	28 Aug 1999 01:08:00 -0000	1.6
> +++ yacc/lr0.c	12 Sep 2001 14:28:04 -0000
> @@ -611,7 +611,7 @@
>  {
>      register int i, j;
>      register int empty;
> -    int done;
> +    int isdone;

As above.

> ...
> Index: yacc/main.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/main.c,v
> retrieving revision 1.12
> diff -u -d -r1.12 main.c
> --- yacc/main.c	10 Jan 2000 20:26:24 -0000	1.12
> +++ yacc/main.c	12 Sep 2001 14:40:50 -0000
> @@ -60,9 +60,9 @@
>  char tflag;
>  char vflag;
>
> -char *symbol_prefix;
> -char *file_prefix = "y";
> -char *temp_form = "yacc.XXXXXXXXXXX";
> +const char *symbol_prefix;
> +const char *file_prefix = "y";
> +const char *temp_form = "yacc.XXXXXXXXXXX";

Use an array for things like this.

> ...
> Index: yacc/output.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/output.c,v
> retrieving revision 1.15
> diff -u -d -r1.15 output.c
> --- yacc/output.c	26 Nov 2000 11:07:45 -0000	1.15
> +++ yacc/output.c	12 Sep 2001 14:45:30 -0000
> @@ -954,6 +954,7 @@
>  {
>      register int i, j, k, max;
>      char **symnam, *s;
> +    static char eof[]="end-of-file";

Missing spaces.

> ...
> Index: yacc/reader.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/reader.c,v
> retrieving revision 1.9
> diff -u -d -r1.9 reader.c
> --- yacc/reader.c	26 Nov 2000 11:07:45 -0000	1.9
> +++ yacc/reader.c	12 Sep 2001 14:48:42 -0000
> @@ -113,6 +113,7 @@
>  static void read_grammar __P((void));
>  static void skip_comment __P((void));
>  static void start_rule __P((bucket *, int));
> +static void declare_expect __P((int));

Don't blindly add to the end of sorted lists!

> @@ -1818,7 +1819,7 @@
>  pack_grammar()
>  {
>      register int i, j;
> -    int assoc, prec;
> +    int assoc, pre;

Rename it something like "preced".

> ...
> Index: yacc/skeleton.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/skeleton.c,v
> retrieving revision 1.29
> diff -u -d -r1.29 skeleton.c
> --- yacc/skeleton.c	19 Feb 2001 01:10:01 -0000	1.29
> +++ yacc/skeleton.c	12 Sep 2001 15:47:52 -0000
> ...
> @@ -128,10 +128,10 @@
>  };
>
>
> -char *body[] =
> +const char *body[] =
>  {
>      "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
> -    "static int yygrowstack()",
> +    "static int yygrowstack(void)",
>      "{",
>      "    int newsize, i;",
>      "    short *newss;",

Gratuitous breakage of K&R support.  The prototype for yygrowstack() is
still correctly ifdefed.

> ...
> Index: yacc/symtab.c
> ...
> Index: yacc/verbose.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/yacc/verbose.c,v
> retrieving revision 1.6
> diff -u -d -r1.6 verbose.c
> --- yacc/verbose.c	28 Aug 1999 01:08:03 -0000	1.6
> +++ yacc/verbose.c	12 Sep 2001 14:59:22 -0000
> @@ -331,9 +331,9 @@
>
>
>  static void
> -print_reductions(p, defred)
> +print_reductions(p, def)
>  register action *p;
> -register int defred;
> +register int def;

Rename it something like "defreduct".

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010914211123.O18340-100000>