fixed topq command
[unix-history] / usr / src / usr.sbin / config / mkioconf.c
index 85d26d8..74400d0 100644 (file)
@@ -1,4 +1,4 @@
-/*     mkioconf.c      2.4     82/10/24        */
+/*     mkioconf.c      2.8     83/06/11        */
 
 #include <stdio.h>
 #include "y.tab.h"
 
 #include <stdio.h>
 #include "y.tab.h"
@@ -18,12 +18,12 @@ vax_ioconf()
        FILE *fp;
 
        fp = fopen(path("ioconf.c"), "w");
        FILE *fp;
 
        fp = fopen(path("ioconf.c"), "w");
-       if (fp == NULL) {
+       if (fp == 0) {
                perror(path("ioconf.c"));
                exit(1);
        }
                perror(path("ioconf.c"));
                exit(1);
        }
+       fprintf(fp, "#include \"../machine/pte.h\"\n");
        fprintf(fp, "#include \"../h/param.h\"\n");
        fprintf(fp, "#include \"../h/param.h\"\n");
-       fprintf(fp, "#include \"../h/pte.h\"\n");
        fprintf(fp, "#include \"../h/buf.h\"\n");
        fprintf(fp, "#include \"../h/map.h\"\n");
        fprintf(fp, "#include \"../h/vm.h\"\n");
        fprintf(fp, "#include \"../h/buf.h\"\n");
        fprintf(fp, "#include \"../h/map.h\"\n");
        fprintf(fp, "#include \"../h/vm.h\"\n");
@@ -36,9 +36,9 @@ vax_ioconf()
         * First print the mba initialization structures
         */
        if (seen_mba) {
         * First print the mba initialization structures
         */
        if (seen_mba) {
-               for (dp = dtab; dp != NULL; dp = dp->d_next) {
+               for (dp = dtab; dp != 0; dp = dp->d_next) {
                        mp = dp->d_conn;
                        mp = dp->d_conn;
-                       if (mp == NULL || mp == TO_NEXUS ||
+                       if (mp == 0 || mp == TO_NEXUS ||
                            !eq(mp->d_name, "mba"))
                                continue;
                        fprintf(fp, "extern struct mba_driver %sdriver;\n",
                            !eq(mp->d_name, "mba"))
                                continue;
                        fprintf(fp, "extern struct mba_driver %sdriver;\n",
@@ -46,9 +46,9 @@ vax_ioconf()
                }
                fprintf(fp, "\nstruct mba_device mbdinit[] = {\n");
                fprintf(fp, "\t/* Device,  Unit, Mba, Drive, Dk */\n");
                }
                fprintf(fp, "\nstruct mba_device mbdinit[] = {\n");
                fprintf(fp, "\t/* Device,  Unit, Mba, Drive, Dk */\n");
-               for (dp = dtab; dp != NULL; dp = dp->d_next) {
+               for (dp = dtab; dp != 0; dp = dp->d_next) {
                        mp = dp->d_conn;
                        mp = dp->d_conn;
-                       if (dp->d_unit == QUES || mp == NULL ||
+                       if (dp->d_unit == QUES || mp == 0 ||
                            mp == TO_NEXUS || !eq(mp->d_name, "mba"))
                                continue;
                        if (dp->d_addr) {
                            mp == TO_NEXUS || !eq(mp->d_name, "mba"))
                                continue;
                        if (dp->d_addr) {
@@ -56,7 +56,7 @@ vax_ioconf()
                                    dp->d_name, dp->d_unit);
                                continue;
                        }
                                    dp->d_name, dp->d_unit);
                                continue;
                        }
-                       if (dp->d_vec != NULL) {
+                       if (dp->d_vec != 0) {
                                printf("can't specify vector for %s%d on mba\n",
                                    dp->d_name, dp->d_unit);
                                continue;
                                printf("can't specify vector for %s%d on mba\n",
                                    dp->d_name, dp->d_unit);
                                continue;
@@ -71,9 +71,9 @@ vax_ioconf()
                                    dp->d_name, dp->d_unit);
                                continue;
                        }
                                    dp->d_name, dp->d_unit);
                                continue;
                        }
-                       fprintf(fp,
-                               "\t{ &%sdriver, %d,   %s,  %s,    %d },\n",
-                               dp->d_name, dp->d_unit, qu(mp->d_unit),
+                       fprintf(fp, "\t{ &%sdriver, %d,   %s,",
+                               dp->d_name, dp->d_unit, qu(mp->d_unit));
+                       fprintf(fp, "  %s,  %d },\n",
                                qu(dp->d_drive), dp->d_dk);
                }
                fprintf(fp, "\t0\n};\n\n");
                                qu(dp->d_drive), dp->d_dk);
                }
                fprintf(fp, "\t0\n};\n\n");
@@ -83,32 +83,32 @@ vax_ioconf()
                 */
                fprintf(fp, "struct mba_slave mbsinit [] = {\n");
                fprintf(fp, "\t/* Driver,  Ctlr, Unit, Slave */\n");
                 */
                fprintf(fp, "struct mba_slave mbsinit [] = {\n");
                fprintf(fp, "\t/* Driver,  Ctlr, Unit, Slave */\n");
-               for (dp = dtab; dp != NULL; dp = dp->d_next) {
+               for (dp = dtab; dp != 0; dp = dp->d_next) {
                        /*
                         * All slaves are connected to something which
                         * is connected to the massbus.
                         */
                        /*
                         * All slaves are connected to something which
                         * is connected to the massbus.
                         */
-                       if ((mp = dp->d_conn) == NULL || mp == TO_NEXUS)
+                       if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS)
                                continue;
                        np = mp->d_conn;
                                continue;
                        np = mp->d_conn;
-                       if (np == NULL || np == TO_NEXUS ||
+                       if (np == 0 || np == TO_NEXUS ||
                            !eq(np->d_name, "mba"))
                                continue;
                            !eq(np->d_name, "mba"))
                                continue;
-                       fprintf(fp,
-                           "\t{ &%sdriver, %s,  %2d,    %s },\n",
-                           mp->d_name, qu(mp->d_unit), dp->d_unit,
-                           qu(dp->d_slave));
+                       fprintf(fp, "\t{ &%sdriver, %s",
+                           mp->d_name, qu(mp->d_unit));
+                       fprintf(fp, ",  %2d,    %s },\n",
+                           dp->d_unit, qu(dp->d_slave));
                }
                fprintf(fp, "\t0\n};\n\n");
        }
        /*
         * Now generate interrupt vectors for the unibus
         */
                }
                fprintf(fp, "\t0\n};\n\n");
        }
        /*
         * Now generate interrupt vectors for the unibus
         */
-       for (dp = dtab; dp != NULL; dp = dp->d_next) {
-               if (dp->d_vec != NULL) {
+       for (dp = dtab; dp != 0; dp = dp->d_next) {
+               if (dp->d_vec != 0) {
                        struct idlst *ip;
                        mp = dp->d_conn;
                        struct idlst *ip;
                        mp = dp->d_conn;
-                       if (mp == NULL || mp == TO_NEXUS ||
+                       if (mp == 0 || mp == TO_NEXUS ||
                            !eq(mp->d_name, "uba"))
                                continue;
                        fprintf(fp,
                            !eq(mp->d_name, "uba"))
                                continue;
                        fprintf(fp,
@@ -139,9 +139,9 @@ vax_ioconf()
        }
        fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n");
        fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n");
        }
        fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n");
        fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n");
-       for (dp = dtab; dp != NULL; dp = dp->d_next) {
+       for (dp = dtab; dp != 0; dp = dp->d_next) {
                mp = dp->d_conn;
                mp = dp->d_conn;
-               if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == NULL ||
+               if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
                    !eq(mp->d_name, "uba"))
                        continue;
                if (dp->d_vec == 0) {
                    !eq(mp->d_name, "uba"))
                        continue;
                if (dp->d_vec == 0) {
@@ -176,16 +176,16 @@ vax_ioconf()
        fprintf(fp, "\nstruct uba_device ubdinit[] = {\n");
        fprintf(fp,
 "\t/* driver,  unit, ctlr,  ubanum, slave,   intr,    addr,    dk, flags*/\n");
        fprintf(fp, "\nstruct uba_device ubdinit[] = {\n");
        fprintf(fp,
 "\t/* driver,  unit, ctlr,  ubanum, slave,   intr,    addr,    dk, flags*/\n");
-       for (dp = dtab; dp != NULL; dp = dp->d_next) {
+       for (dp = dtab; dp != 0; dp = dp->d_next) {
                mp = dp->d_conn;
                mp = dp->d_conn;
-               if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == NULL ||
+               if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
                    mp == TO_NEXUS || mp->d_type == MASTER ||
                    eq(mp->d_name, "mba"))
                        continue;
                np = mp->d_conn;
                    mp == TO_NEXUS || mp->d_type == MASTER ||
                    eq(mp->d_name, "mba"))
                        continue;
                np = mp->d_conn;
-               if (np != NULL && np != TO_NEXUS && eq(np->d_name, "mba"))
+               if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba"))
                        continue;
                        continue;
-               np = NULL;
+               np = 0;
                if (eq(mp->d_name, "uba")) {
                        if (dp->d_vec == 0) {
                                printf("must specify vector for device %s%d\n",
                if (eq(mp->d_name, "uba")) {
                        if (dp->d_vec == 0) {
                                printf("must specify vector for device %s%d\n",
@@ -207,7 +207,7 @@ vax_ioconf()
                        uba_n = mp->d_unit;
                        slave = QUES;
                } else {
                        uba_n = mp->d_unit;
                        slave = QUES;
                } else {
-                       if ((np = mp->d_conn) == NULL) {
+                       if ((np = mp->d_conn) == 0) {
                                printf("%s%d isn't connected to anything ",
                                    mp->d_name, mp->d_unit);
                                printf(", so %s%d is unattached\n",
                                printf("%s%d isn't connected to anything ",
                                    mp->d_name, mp->d_unit);
                                printf(", so %s%d is unattached\n",
@@ -242,26 +242,27 @@ vax_ioconf()
                        }
                        slave = dp->d_drive;
                }
                        }
                        slave = dp->d_drive;
                }
-               fprintf(fp,
-"\t{ &%sdriver,  %2d,   %s,  %s,    %2d,   %s, C 0%-6o,  %d,  0x%x },\n",
+               fprintf(fp, "\t{ &%sdriver,  %2d,   %s,",
                    eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit,
                    eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit,
-                   eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit), qu(uba_n),
-                   slave, intv(dp), dp->d_addr, dp->d_dk, dp->d_flags);
+                   eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit));
+               fprintf(fp, "  %s,    %2d,   %s, C 0%-6o,  %d,  0x%x },\n",
+                   qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk,
+                   dp->d_flags);
        }
        fprintf(fp, "\t0\n};\n");
        }
        fprintf(fp, "\t0\n};\n");
-       fclose(fp);
+       (void) fclose(fp);
 }
 #endif
 
 #if MACHINE_SUN
 sun_ioconf()
 {
 }
 #endif
 
 #if MACHINE_SUN
 sun_ioconf()
 {
-       register struct device *dp, *mp, *np;
-       register int uba_n, slave;
+       register struct device *dp, *mp;
+       register int slave;
        FILE *fp;
 
        fp = fopen(path("ioconf.c"), "w");
        FILE *fp;
 
        fp = fopen(path("ioconf.c"), "w");
-       if (fp == NULL) {
+       if (fp == 0) {
                perror(path("ioconf.c"));
                exit(1);
        }
                perror(path("ioconf.c"));
                exit(1);
        }
@@ -270,17 +271,17 @@ sun_ioconf()
        fprintf(fp, "#include \"../h/map.h\"\n");
        fprintf(fp, "#include \"../h/vm.h\"\n");
        fprintf(fp, "\n");
        fprintf(fp, "#include \"../h/map.h\"\n");
        fprintf(fp, "#include \"../h/vm.h\"\n");
        fprintf(fp, "\n");
-       fprintf(fp, "#include \"../sunmb/mbvar.h\"\n");
+       fprintf(fp, "#include \"../sundev/mbvar.h\"\n");
        fprintf(fp, "\n");
        fprintf(fp, "#define C (caddr_t)\n\n");
        fprintf(fp, "\n");
        /*
         * Now generate interrupt vectors for the Multibus
         */
        fprintf(fp, "\n");
        fprintf(fp, "#define C (caddr_t)\n\n");
        fprintf(fp, "\n");
        /*
         * Now generate interrupt vectors for the Multibus
         */
-       for (dp = dtab; dp != NULL; dp = dp->d_next) {
-               if (dp->d_pri != NULL) {
+       for (dp = dtab; dp != 0; dp = dp->d_next) {
+               if (dp->d_pri != 0) {
                        mp = dp->d_conn;
                        mp = dp->d_conn;
-                       if (mp == NULL || mp == TO_NEXUS ||
+                       if (mp == 0 || mp == TO_NEXUS ||
                            !eq(mp->d_name, "mb"))
                                continue;
                        fprintf(fp, "extern struct mb_driver %sdriver;\n",
                            !eq(mp->d_name, "mb"))
                                continue;
                        fprintf(fp, "extern struct mb_driver %sdriver;\n",
@@ -292,9 +293,9 @@ sun_ioconf()
         */
        fprintf(fp, "\nstruct mb_ctlr mbcinit[] = {\n");
        fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n");
         */
        fprintf(fp, "\nstruct mb_ctlr mbcinit[] = {\n");
        fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n");
-       for (dp = dtab; dp != NULL; dp = dp->d_next) {
+       for (dp = dtab; dp != 0; dp = dp->d_next) {
                mp = dp->d_conn;
                mp = dp->d_conn;
-               if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == NULL ||
+               if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
                    !eq(mp->d_name, "mb"))
                        continue;
                if (dp->d_pri == 0) {
                    !eq(mp->d_name, "mb"))
                        continue;
                if (dp->d_pri == 0) {
@@ -329,13 +330,12 @@ sun_ioconf()
        fprintf(fp, "\nstruct mb_device mbdinit[] = {\n");
        fprintf(fp,
 "\t/* driver,  unit, ctlr,  slave,   addr,    pri,    dk, flags*/\n");
        fprintf(fp, "\nstruct mb_device mbdinit[] = {\n");
        fprintf(fp,
 "\t/* driver,  unit, ctlr,  slave,   addr,    pri,    dk, flags*/\n");
-       for (dp = dtab; dp != NULL; dp = dp->d_next) {
+       for (dp = dtab; dp != 0; dp = dp->d_next) {
                mp = dp->d_conn;
                mp = dp->d_conn;
-               if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == NULL ||
+               if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
                    mp == TO_NEXUS || mp->d_type == MASTER ||
                    eq(mp->d_name, "mba"))
                        continue;
                    mp == TO_NEXUS || mp->d_type == MASTER ||
                    eq(mp->d_name, "mba"))
                        continue;
-               np = NULL;
                if (eq(mp->d_name, "mb")) {
                        if (dp->d_pri == 0) {
                                printf("must specify vector for device %s%d\n",
                if (eq(mp->d_name, "mb")) {
                        if (dp->d_pri == 0) {
                                printf("must specify vector for device %s%d\n",
@@ -355,7 +355,7 @@ sun_ioconf()
                        }
                        slave = QUES;
                } else {
                        }
                        slave = QUES;
                } else {
-                       if ((np = mp->d_conn) == NULL) {
+                       if (mp->d_conn == 0) {
                                printf("%s%d isn't connected to anything, ",
                                    mp->d_name, mp->d_unit);
                                printf("so %s%d is unattached\n",
                                printf("%s%d isn't connected to anything, ",
                                    mp->d_name, mp->d_unit);
                                printf("so %s%d is unattached\n",
@@ -396,7 +396,7 @@ sun_ioconf()
                    slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags);
        }
        fprintf(fp, "\t0\n};\n");
                    slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags);
        }
        fprintf(fp, "\t0\n};\n");
-       fclose(fp);
+       (void) fclose(fp);
 }
 #endif
 
 }
 #endif
 
@@ -407,8 +407,7 @@ char *intv(dev)
 
        if (dev->d_vec == 0)
                return ("     0");
 
        if (dev->d_vec == 0)
                return ("     0");
-       else
-               return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit));
+       return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit));
 }
 
 char *
 }
 
 char *
@@ -417,8 +416,7 @@ qu(num)
 
        if (num == QUES)
                return ("'?'");
 
        if (num == QUES)
                return ("'?'");
-       else if (num == UNKNOWN)
+       if (num == UNKNOWN)
                return (" -1");
                return (" -1");
-       else
-               return (ns(sprintf(errbuf, "%3d", num)));
+       return (sprintf(errbuf, "%3d", num));
 }
 }