Module Name:    src
Committed By:   kre
Date:           Sun Aug 26 11:48:00 UTC 2018

Modified Files:
        src/sys/kern: makesyscalls.sh

Log Message:
Validate that the configuration parameters that are supposed to
be numeric are in fact numeric, and then have the awk script use
them as awk numbers, rather than strings, so awk isn't doing string
comparisons on numbers (where "1024" < 2).

This has no effect with current configuratons, but would if anyone
had ever attempted to configure a system with nsysent >= 1000


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/kern/makesyscalls.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/makesyscalls.sh
diff -u src/sys/kern/makesyscalls.sh:1.170 src/sys/kern/makesyscalls.sh:1.171
--- src/sys/kern/makesyscalls.sh:1.170	Fri Aug 10 21:44:59 2018
+++ src/sys/kern/makesyscalls.sh	Sun Aug 26 11:48:00 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: makesyscalls.sh,v 1.170 2018/08/10 21:44:59 pgoyette Exp $
+#	$NetBSD: makesyscalls.sh,v 1.171 2018/08/26 11:48:00 kre Exp $
 #
 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
 # All rights reserved.
@@ -78,6 +78,15 @@ case $1 in
 *)	. ./$1;;
 esac
 
+fail=false
+case "${nsysent:-0}" in
+*[!0-9]*) fail=true; printf >&2 '%s\n' "Non numeric value for nsysent";;
+esac
+case "${maxsysargs:-0}" in
+*[!0-9]*) fail=true; printf >&2 '%s\n' "Non numeric value for maxsysargs";;
+esac
+$fail && exit 1
+
 # tmp files:
 sysdcl="sysent.dcl"
 sysprotos="sys.protos"
@@ -172,7 +181,7 @@ BEGIN {
 	if (!registertype) {
 	    registertype = \"register_t\"
 	}
-	nsysent = \"$nsysent\"
+	nsysent = ${nsysent:-0}
 
 	sysdcl = \"$sysdcl\"
 	syscompat_pref = \"$syscompat_pref\"
@@ -182,7 +191,7 @@ BEGIN {
 	rumpprotos = \"$rumpprotos\"
 	rumptypes = \"$rumptypes\"
 	sys_nosys = \"$sys_nosys\"
-	maxsysargs = \"$maxsysargs\"
+	maxsysargs = ${maxsysargs:-8}
 	rumpnoflags=\"$rumpnoflags\"
 	rumpnosys=\"$rumpnosys\"
 	rumpnomodule=\"$rumpnomodule\"
@@ -1130,12 +1139,6 @@ END {
 
 	maxsyscall = syscall
 
-	# XXX
-	# XXX The following comparisons with nsysent will produce
-	# XXX unexpected results if (for example) syscall has a
-	# XXX value of 900 and nsysent has a value of "1024".  We
-	# XXX probably ought to make nsysent a numeric variable.
-	# XXX
 	if (nsysent) {
 		if (syscall > nsysent) {
 			printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)

Reply via email to