Subject: local cleanup of magic numbers in if_gm.c
To: 'port-powerpc@netbsd.org' <port-powerpc@netbsd.org>
From: Bruce Korb <bkorb@allegronetworks.com>
List: port-powerpc
Date: 04/18/2001 13:14:03
I prefer symbolic constants:

==== netbsd/usr/src/sys/arch/macppc/dev/if_gm.c#1 -
/home/bkorb/olive/sys/arch/macppc/dev/if_gm.c ====
@@ -182,19 +182,21 @@
                return;
        }
 
-       /* Setup packet buffers and dma descriptors. */
-       p = malloc((NRXBUF + NTXBUF) * 2048 + 3 * 0x800, M_DEVBUF,
M_NOWAIT);
+       /* Setup packet buffers, dma descriptors and alignment spare. */
+       #define BUFCT (NRXBUF + NXTBUF + 2)
+       #define BUFSZ 0x800
+       p = malloc((BUFCT + 1) * BUFSZ, M_DEVBUF, M_NOWAIT);
        if (p == NULL) {
                printf(": cannot malloc buffers\n");
                return;
        }
-       p = (void *)roundup((vaddr_t)p, 0x800);
-       bzero(p, 2048 * (NRXBUF + NTXBUF) + 2 * 0x800);
+       p = (void *)roundup((vaddr_t)p, BUFSZ);
+       bzero(p, 2048 * BUFCT);
 
        sc->sc_rxlist = (void *)p;
-       p += 0x800;
+       p += BUFSZ;
        sc->sc_txlist = (void *)p;
-       p += 0x800;
+       p += BUFSZ;
 
        dp = sc->sc_rxlist;
        for (i = 0; i < NRXBUF; i++) {
@@ -202,7 +204,7 @@
                dp->address = htole32(vtophys((vaddr_t)p));
                dp->cmd = htole32(GMAC_OWN);
                dp++;
-               p += 2048;
+               p += BUFSZ;
        }
 
        dp = sc->sc_txlist;
@@ -210,8 +212,10 @@
                sc->sc_txbuf[i] = p;
                dp->address = htole32(vtophys((vaddr_t)p));
                dp++;
-               p += 2048;
+               p += BUFSZ;
        }
+       #undef BUFSZ
+       #undef BUFCT
 
        printf(": Ethernet address %s\n", ether_sprintf(laddr));
        printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);