Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc improve error checking, and bail out early, instead of l...



details:   https://anonhg.NetBSD.org/src/rev/808d95e829f4
branches:  trunk
changeset: 553481:808d95e829f4
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Oct 17 19:01:49 2003 +0000

description:
improve error checking, and bail out early, instead of looping
when filtering the template, leave only the wanted makedisk_p*() routine
in the output
as pointed out by David Laight

also make it mandatory for MACHINE and MACHINE_ARCH to be set in
environment; it would be possible to use use uname -p/-m, but better
to catch possible cross-build mistakes sooner than later

diffstat:

 etc/MAKEDEV.awk |  31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diffs (66 lines):

diff -r 358c900a815c -r 808d95e829f4 etc/MAKEDEV.awk
--- a/etc/MAKEDEV.awk   Fri Oct 17 18:49:11 2003 +0000
+++ b/etc/MAKEDEV.awk   Fri Oct 17 19:01:49 2003 +0000
@@ -1,6 +1,6 @@
 #!/usr/bin/awk -
 #
-#      $NetBSD: MAKEDEV.awk,v 1.3 2003/10/15 21:40:49 itojun Exp $
+#      $NetBSD: MAKEDEV.awk,v 1.4 2003/10/17 19:01:49 jdolecek Exp $
 #
 # Copyright (c) 2003 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -51,14 +51,16 @@
                top = ".."
        top = top "/sys/"
        if (system("test -d '" top "'") != 0) {
-               print "ERROR: didn't find top of kernel tree ('" top "' not a directory)" > "/dev/stderr"
+               print "ERROR: can't find top of kernel source tree ('" top "' not a directory)" > "/dev/stderr"
                exit 1
        }
 
        machine = ENVIRON["MACHINE"]
-       if (!machine)
-               machine = "i386"        # XXX for testing
        maarch = ENVIRON["MACHINE_ARCH"]
+       if (!machine || !maarch) {
+               print "ERROR: 'MACHINE' and 'MACHINE_ARCH' must be set in environment" > "/dev/stderr"
+               exit 1
+       }
 
        # file with major definitions
        majors[0] = "conf/majors"
@@ -74,6 +76,11 @@
        # arrays, used in template processing
        for (m in majors) {
                file = top majors[m]
+               if (system("test -f '" file "'") != 0) {
+                       print "ERROR: can't find majors file '" file "'" > "/dev/stderr"
+                       exit 1
+               }
+                       
                while (getline < file) {
                        if ($1 == "device-major") {
                                if ($3 == "char") {
@@ -119,6 +126,22 @@
        next
 }
 
+# filter the two unneeded makedisk_p* routines, leave only
+# the one used
+/^makedisk_p8\(\) {/, /^}/ {
+       if (MKDISK != "makedisk_p8")
+               next;
+}
+/^makedisk_p16\(\) {/, /^}/ {
+       if (MKDISK != "makedisk_p16")
+               next;
+}
+/^makedisk_p16high\(\) {/, /^}/ {
+       if (MKDISK != "makedisk_p16high")
+               next;
+}
+
+# special cases aside, handle normal line 
 {
        sub("^%MD_DEVICES%", MDDEV)
        sub("%MKDISK%", MKDISK)



Home | Main Index | Thread Index | Old Index