AMD64 - Fix many compile-time warnings. int/ptr type mismatches, %llx, etc.
[dragonfly.git] / sys / dev / disk / md / md.c
index 61395ba..103a486 100644 (file)
@@ -7,7 +7,7 @@
  * ----------------------------------------------------------------------------
  *
  * $FreeBSD: src/sys/dev/md/md.c,v 1.8.2.2 2002/08/19 17:43:34 jdp Exp $
- * $DragonFly: src/sys/dev/disk/md/md.c,v 1.18 2007/09/05 05:28:32 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/md/md.c,v 1.20 2008/09/07 08:09:39 swildner Exp $
  *
  */
 
@@ -136,7 +136,8 @@ mdstrategy(struct dev_strategy_args *ap)
 
        if (md_debug > 1) {
                kprintf("mdstrategy(%p) %s %08x, %lld, %d, %p)\n",
-                   bp, devtoname(dev), bp->b_flags, bio->bio_offset, 
+                   bp, devtoname(dev), bp->b_flags,
+                   (long long)bio->bio_offset,
                    bp->b_bcount, bp->b_data);
        }
        bio->bio_driver_info = dev;
@@ -158,13 +159,13 @@ mdstrategy_malloc(struct dev_strategy_args *ap)
        struct buf *bp = bio->bio_buf;
        unsigned secno, nsec, secval, uc;
        u_char *secp, **secpp, *dst;
-       devstat_trans_flags dop;
        struct md_s *sc;
        int i;
 
        if (md_debug > 1)
                kprintf("mdstrategy_malloc(%p) %s %08xx, %lld, %d, %p)\n",
-                   bp, devtoname(dev), bp->b_flags, bio->bio_offset, 
+                   bp, devtoname(dev), bp->b_flags,
+                   (long long)bio->bio_offset,
                    bp->b_bcount, bp->b_data);
 
        sc = dev->si_drv1;
@@ -192,15 +193,10 @@ mdstrategy_malloc(struct dev_strategy_args *ap)
 
                devstat_start_transaction(&sc->stats);
 
-               switch(bp->b_cmd) {
+               switch (bp->b_cmd) {
                case BUF_CMD_FREEBLKS:
-                       dop = DEVSTAT_NO_DATA;
-                       break;
                case BUF_CMD_READ:
-                       dop = DEVSTAT_READ;
-                       break;
                case BUF_CMD_WRITE:
-                       dop = DEVSTAT_WRITE;
                        break;
                default:
                        panic("md: bad b_cmd %d", bp->b_cmd);
@@ -212,12 +208,12 @@ mdstrategy_malloc(struct dev_strategy_args *ap)
                while (nsec--) {
                        if (secno < sc->nsecp) {
                                secpp = &sc->secp[secno];
-                               if ((u_int)*secpp > 255) {
+                               if ((u_int)(uintptr_t)*secpp > 255) {
                                        secp = *secpp;
                                        secval = 0;
                                } else {
                                        secp = 0;
-                                       secval = (u_int) *secpp;
+                                       secval = (u_int)(uintptr_t)*secpp;
                                }
                        } else {
                                secpp = 0;
@@ -227,7 +223,7 @@ mdstrategy_malloc(struct dev_strategy_args *ap)
                        if (md_debug > 2)
                                kprintf("%08x %p %p %d\n", bp->b_flags, secpp, secp, secval);
 
-                       switch(bp->b_cmd) {
+                       switch (bp->b_cmd) {
                        case BUF_CMD_FREEBLKS:
                                if (secpp) {
                                        if (secp)
@@ -254,11 +250,10 @@ mdstrategy_malloc(struct dev_strategy_args *ap)
                                        if (secp)
                                                FREE(secp, M_MDSECT);
                                        if (secpp)
-                                               *secpp = (u_char *)uc;
+                                               *secpp = (u_char *)(uintptr_t)uc;
                                } else {
                                        if (!secpp) {
-                                               MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK);
-                                               bzero(secpp, (secno + nsec + 1) * sizeof(u_char *));
+                                               MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK | M_ZERO);
                                                bcopy(sc->secp, secpp, sc->nsecp * sizeof(u_char *));
                                                FREE(sc->secp, M_MD);
                                                sc->secp = secpp;
@@ -268,7 +263,7 @@ mdstrategy_malloc(struct dev_strategy_args *ap)
                                        if (i == DEV_BSIZE) {
                                                if (secp)
                                                        FREE(secp, M_MDSECT);
-                                               *secpp = (u_char *)uc;
+                                               *secpp = (u_char *)(uintptr_t)uc;
                                        } else {
                                                if (!secp) 
                                                        MALLOC(secp, u_char *, DEV_BSIZE, M_MDSECT, M_WAITOK);
@@ -301,12 +296,12 @@ mdstrategy_preload(struct dev_strategy_args *ap)
        cdev_t dev = ap->a_head.a_dev;
        struct bio *bio = ap->a_bio;
        struct buf *bp = bio->bio_buf;
-       devstat_trans_flags dop;
        struct md_s *sc;
 
        if (md_debug > 1)
                kprintf("mdstrategy_preload(%p) %s %08x, %lld, %d, %p)\n",
-                   bp, devtoname(dev), bp->b_flags, bio->bio_offset, 
+                   bp, devtoname(dev), bp->b_flags,
+                   (long long)bio->bio_offset,
                    bp->b_bcount, bp->b_data);
 
        sc = dev->si_drv1;
@@ -332,17 +327,14 @@ mdstrategy_preload(struct dev_strategy_args *ap)
 
                devstat_start_transaction(&sc->stats);
 
-               switch(bp->b_cmd) {
+               switch (bp->b_cmd) {
                case BUF_CMD_FREEBLKS:
-                       dop = DEVSTAT_NO_DATA;
                        break;
                case BUF_CMD_READ:
-                       dop = DEVSTAT_READ;
                        bcopy(sc->pl_ptr + bio->bio_offset, 
                               bp->b_data, bp->b_bcount);
                        break;
                case BUF_CMD_WRITE:
-                       dop = DEVSTAT_WRITE;
                        bcopy(bp->b_data, sc->pl_ptr + bio->bio_offset,
                              bp->b_bcount);
                        break;
@@ -363,8 +355,7 @@ mdcreate(void)
 {
        struct md_s *sc;
 
-       MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK);
-       bzero(sc, sizeof(*sc));
+       MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK | M_ZERO);
        sc->unit = mdunits++;
        bioq_init(&sc->bio_queue);
        devstat_add_entry(&sc->stats, "md", sc->unit, DEV_BSIZE,
@@ -402,8 +393,7 @@ mdcreate_malloc(void)
        sc->type = MD_MALLOC;
 
        sc->nsect = MD_NSECT;   /* for now */
-       MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK);
-       bzero(sc->secp, sizeof(u_char *));
+       MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK | M_ZERO);
        sc->nsecp = 1;
        kprintf("md%d: Malloc disk\n", sc->unit);
 }