Subject: gcc-current and warnings in bin/sh
To: None <tech-userlevel@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-userlevel
Date: 05/31/2002 08:29:10
--KqBSqvdnnccM6+Kg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Without the following patch, gcc-current issues the following warnings
when building bin/sh (-Werror turned off to demonstrate):

yeah-baby:thorpej 12$ NOGCCERROR=yes sudo nbmake-hp300-hp380 
/usr/local/gnu/bin/m68k-unknown-netbsdelf-gcc -O2 -m68040 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wreturn-type -Wpointer-arith -Wswitch -Wshadow    -DSHELL -I. -I/u1/netbsd/src/bin/sh -nostdinc -isystem /u1/diskless/hp380/usr/include  -c /u1/netbsd/src/bin/sh/eval.c
/u1/netbsd/src/bin/sh/eval.c: In function `evalcommand':
/u1/netbsd/src/bin/sh/eval.c:641: warning: comparison is always true due to limited range of data type
/u1/netbsd/src/bin/sh/eval.c:644: warning: comparison is always true due to limited range of data type
/usr/local/gnu/bin/m68k-unknown-netbsdelf-gcc -O2 -m68040 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wreturn-type -Wpointer-arith -Wswitch -Wshadow    -DSHELL -I. -I/u1/netbsd/src/bin/sh -nostdinc -isystem /u1/diskless/hp380/usr/include  -c /u1/netbsd/src/bin/sh/parser.c
/u1/netbsd/src/bin/sh/parser.c: In function `goodname':
/u1/netbsd/src/bin/sh/parser.c:1556: warning: comparison is always true due to limited range of data type
/u1/netbsd/src/bin/sh/parser.c:1559: warning: comparison is always true due to limited range of data type
/usr/local/gnu/bin/m68k-unknown-netbsdelf-gcc -O2 -m68040 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wreturn-type -Wpointer-arith -Wswitch -Wshadow    -DSHELL -I. -I/u1/netbsd/src/bin/sh -nostdinc -isystem /u1/diskless/hp380/usr/include  -c /u1/netbsd/src/bin/sh/var.c
/u1/netbsd/src/bin/sh/var.c: In function `setvar':
/u1/netbsd/src/bin/sh/var.c:238: warning: comparison is always true due to limited range of data type
/u1/netbsd/src/bin/sh/var.c:242: warning: comparison is always true due to limited range of data type
/usr/local/gnu/bin/m68k-unknown-netbsdelf-gcc -O2 -m68040 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wreturn-type -Wpointer-arith -Wswitch -Wshadow    -DSHELL -I. -I/u1/netbsd/src/bin/sh -nostdinc -isystem /u1/diskless/hp380/usr/include  -c init.c
/usr/local/gnu/bin/m68k-unknown-netbsdelf-gcc  -static -o sh -nostdlib  /u1/diskless/hp380/usr/lib/crt0.o /u1/diskless/hp380/usr/lib/crtbegin.o alias.o cd.o echo.o error.o eval.o exec.o expand.o histedit.o input.o jobs.o mail.o main.o memalloc.o miscbltin.o mystring.o options.o parser.o redir.o show.o trap.o output.o var.o test.o arith.o arith_lex.o builtins.o init.o nodes.o syntax.o -ll -ledit -ltermcap -L/u1/diskless/hp380/usr/lib  -lgcc -lc -lgcc /u1/diskless/hp380/usr/lib/crtend.o

I'm not entirely convinced that the patch is correct... definitely want
comments...

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

--KqBSqvdnnccM6+Kg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=sh-patch

Index: eval.c
===================================================================
RCS file: /cvsroot/basesrc/bin/sh/eval.c,v
retrieving revision 1.59
diff -u -r1.59 eval.c
--- eval.c	2002/05/15 16:33:35	1.59
+++ eval.c	2002/05/31 15:20:20
@@ -638,10 +638,11 @@
 	exitstatus = 0;
 	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
 		char *p = argp->narg.text;
-		if (varflag && is_name(*p)) {
+		int c;
+		if (varflag && is_name((c = *p))) {
 			do {
 				p++;
-			} while (is_in_name(*p));
+			} while (is_in_name((c = *p)));
 			if (*p == '=') {
 				expandarg(argp, &varlist, EXP_VARTILDE);
 				continue;
Index: expand.c
===================================================================
RCS file: /cvsroot/basesrc/bin/sh/expand.c,v
retrieving revision 1.53
diff -u -r1.53 expand.c
--- expand.c	2002/05/15 14:59:21	1.53
+++ expand.c	2002/05/31 15:20:22
@@ -640,7 +640,7 @@
 	subtype = varflags & VSTYPE;
 	var = p;
 	special = 0;
-	if (! is_name(*p))
+	if (! is_name((c = *p)))
 		special = 1;
 	p = strchr(p, '=') + 1;
 again: /* jump here after setting a variable with ${var=text} */
Index: parser.c
===================================================================
RCS file: /cvsroot/basesrc/bin/sh/parser.c,v
retrieving revision 1.53
diff -u -r1.53 parser.c
--- parser.c	2002/05/15 16:33:35	1.53
+++ parser.c	2002/05/31 15:20:23
@@ -1551,12 +1551,13 @@
 goodname(char *name)
 	{
 	char *p;
+	int c;
 
 	p = name;
-	if (! is_name(*p))
+	if (! is_name((c = *p)))
 		return 0;
 	while (*++p) {
-		if (! is_in_name(*p))
+		if (! is_in_name((c = *p)))
 			return 0;
 	}
 	return 1;
Index: var.c
===================================================================
RCS file: /cvsroot/basesrc/bin/sh/var.c,v
retrieving revision 1.28
diff -u -r1.28 var.c
--- var.c	2002/05/15 19:43:29	1.28
+++ var.c	2002/05/31 15:20:23
@@ -232,14 +232,15 @@
 	int namelen;
 	char *nameeq;
 	int isbad;
+	int c;
 
 	isbad = 0;
 	p = name;
-	if (! is_name(*p))
+	if (! is_name((c = *p)))
 		isbad = 1;
 	p++;
 	for (;;) {
-		if (! is_in_name(*p)) {
+		if (! is_in_name((c = *p))) {
 			if (*p == '\0' || *p == '=')
 				break;
 			isbad = 1;

--KqBSqvdnnccM6+Kg--