NetBSD-Bugs archive

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

Re: lib/39215: getdevmajor()/major() types don't match



The following reply was made to PR lib/39215; it has been noted by GNATS.

From: Matthias Drochner <M.Drochner%fz-juelich.de@localhost>
To: M.Drochner%fz-juelich.de@localhost
Cc: christos%zoulas.com@localhost (Christos Zoulas), 
gnats-bugs%NetBSD.org@localhost,
        lib-bug-people%NetBSD.org@localhost, gnats-admin%NetBSD.org@localhost,
        netbsd-bugs%NetBSD.org@localhost, dholland%eecs.harvard.edu@localhost
Subject: Re: lib/39215: getdevmajor()/major() types don't match 
Date: Mon, 04 Aug 2008 23:05:20 +0200

 This is a multipart MIME message.
 
 --==_Exmh_10139695340550
 Content-Type: text/plain; charset=us-ascii
 
 
 M.Drochner%fz-juelich.de@localhost said:
 > That's all not too serious, but it is more work than one would
 > initially expect. I'll try to come up with patches. 
 
 OK, here is it. I've just set devmajor/minor_t to "long"
 to get compiler warnings. It should stay where it was,
 at int32_t, for now. (Actually, I don't see a good reason to
 use a fixed-size type here, it is all inside the API afaics.)
 So the typecasts for printf which make out most of the patch
 are not necessary, but they show what happens if one really
 wants to use 64 bit for majors or so.
 
 best regards
 Matthias
 
 
 
 
 
 
 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich
 
 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------
 
 --==_Exmh_10139695340550
 Content-Type: text/plain ; name="maj.txt"; charset=us-ascii
 Content-Description: maj.txt
 Content-Disposition: attachment; filename="maj.txt"
 
 ============================================================
 --- bin/ls/print.c     2650499ccb0cd28a38500fd11d1729da0b48131d
 +++ bin/ls/print.c     ea75bc1455312f2ddd29753f4daa8a435e2daa8c
 @@ -139,8 +139,8 @@ printlong(DISPLAY *dp)
                        (void)printf("%-*s ", dp->s_flags, np->flags);
                if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
                        (void)printf("%*u, %*u ",
 -                          dp->s_major, major(sp->st_rdev), dp->s_minor,
 -                          minor(sp->st_rdev));
 +                          dp->s_major, (unsigned)major(sp->st_rdev),
 +                          dp->s_minor, (unsigned)minor(sp->st_rdev));
                else
                        if (f_humanize) {
                                if ((humanize_number(szbuf, sizeof(szbuf),
 ============================================================
 --- bin/ps/print.c     945c4bf0d44f87cde7f530324777616c76facd1b
 +++ bin/ps/print.c     40a5d4930a84a7ed079155716daea55bfeee7cb3
 @@ -715,7 +715,7 @@ tdev(void *arg, VARENT *ve, int mode)
                                v->width = 2;
        } else {
                (void)snprintf(buff, sizeof(buff),
 -                  "%d/%d", major(dev), minor(dev));
 +                  "%d/%d", (int)major(dev), (int)minor(dev));
                strprintorsetwidth(v, buff, mode);
        }
  }
 ============================================================
 --- include/stdlib.h   88c992035e9fc9a987d6bbd51ed517126c84252c
 +++ include/stdlib.h   fd62f316416514ef631c061192e7564d189d1064
 @@ -278,7 +278,7 @@ int         dehumanize_number(const char *, int
  int    humanize_number(char *, size_t, int64_t, const char *, int, int);
  int    dehumanize_number(const char *, int64_t *);
  
 -dev_t  getdevmajor(const char *, mode_t);
 +devmajor_t getdevmajor(const char *, mode_t);
  int    getloadavg(double [], int);
  
  int    getenv_r(const char *, char *, size_t);
 ============================================================
 --- lib/libc/gen/devname.c     fc188811536b897bb2cfaeefea452b85edef7fd4
 +++ lib/libc/gen/devname.c     84adf45c2042517c2e1ac0448adc845b87ec6db1
 @@ -113,7 +113,7 @@ devname(dev, type)
        DBT data, key;
        DEVC *ptr, **pptr;
        static DEVC **devtb = NULL;
 -      static dev_t pts = (dev_t)~1;
 +      static devmajor_t pts = -2;
  
        if (!db && !failure &&
            !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) {
 @@ -165,12 +165,12 @@ devname(dev, type)
                        return (NULL);
                ptr->valid = INVALID;
                if (type == S_IFCHR) {
 -                      if (pts == (dev_t)~1)
 +                      if (pts == -2)
                                pts = getdevmajor("pts", S_IFCHR);
 -                      if (pts != (dev_t)~0 && major(dev) == pts) {
 +                      if (pts != NODEVMAJOR && major(dev) == pts) {
                                (void)snprintf(ptr->name, sizeof(ptr->name),
                                    "%s%d", _PATH_DEV_PTS +
 -                                  sizeof(_PATH_DEV) - 1, minor(dev));
 +                                  sizeof(_PATH_DEV) - 1, (int)minor(dev));
                                ptr->valid = VALID;
                        }
                }
 ============================================================
 --- lib/libc/gen/getdevmajor.c 8d741a93bb4ddb0f918f7da5ef4c54b8c9d10141
 +++ lib/libc/gen/getdevmajor.c 0c4e97f74e067d924f7aedd5ec379807c5e8d04f
 @@ -51,13 +51,13 @@ __weak_alias(getdevmajor,_getdevmajor)
  __weak_alias(getdevmajor,_getdevmajor)
  #endif
  
 -dev_t
 +devmajor_t
  getdevmajor(const char *name, mode_t type)
  {
        struct kinfo_drivers kd[200], *kdp = &kd[0];
        int rc, i;
        size_t sz = sizeof(kd);
 -      dev_t n = (dev_t)~0;
 +      devmajor_t n = NODEVMAJOR;
  
        if (type != S_IFCHR && type != S_IFBLK) {
                errno = EINVAL;
 ============================================================
 --- libexec/ftpd/cmds.c        70685c8d7f3336bf7b1d1a4241a3535e927decc4
 +++ libexec/ftpd/cmds.c        f71a202c8dee691da7369907d5c1070f815e9577
 @@ -762,7 +762,8 @@ fact_type(const char *fact, FILE *fd, fa
        case S_IFCHR:
                cprintf(fd, "OS.unix=%s-%d/%d",
                    S_ISBLK(fe->stat->st_mode) ? "blk" : "chr",
 -                  major(fe->stat->st_rdev), minor(fe->stat->st_rdev));
 +                  (int)major(fe->stat->st_rdev),
 +                  (int)minor(fe->stat->st_rdev));
                break;
        default:
                cprintf(fd, "OS.unix=UNKNOWN(0%o)", fe->stat->st_mode & S_IFMT);
 ============================================================
 --- sbin/fsdb/fsdbutil.c       6681b3da9ec2038d4a91c88ad47162da288b0754
 +++ sbin/fsdb/fsdbutil.c       c423dc5ef36d39ee6d6f786a417fb3b872da1141
 @@ -113,10 +113,12 @@ printstat(const char *cp, ino_t inum, un
                puts("regular file");
                break;
        case IFBLK:
 -              printf("block special (%d,%d)", major(rdev), minor(rdev));
 +              printf("block special (%d,%d)",
 +                     (int)major(rdev), (int)minor(rdev));
                break;
        case IFCHR:
 -              printf("character special (%d,%d)", major(rdev), minor(rdev));
 +              printf("character special (%d,%d)",
 +                     (int)major(rdev), (int)minor(rdev));
                break;
        case IFLNK:
                fputs("symlink", stdout);
 ============================================================
 --- sbin/mknod/mknod.c d941c3f90d438327ec9a4a479787bba90b54825e
 +++ sbin/mknod/mknod.c 448ecbfb99301117c80fa46ad5cd406123c579fd
 @@ -364,9 +364,11 @@ print_device_info(char **names)
                                continue;
                        printf("%s", kd->d_name);
                        if (kd->d_cmajor != -1)
 -                              printf(" character major %d", kd->d_cmajor);
 +                              printf(" character major %d",
 +                                     (int)kd->d_cmajor);
                        if (kd->d_bmajor != -1)
 -                              printf(" block major %d", kd->d_bmajor);
 +                              printf(" block major %d",
 +                                     (int)kd->d_bmajor);
                        printf("\n");
                }
        } while (*names && *++names);
 ============================================================
 --- sbin/savecore/savecore.c   2577ea2b9f34bf55bc26d55ff367b40eff9aa153
 +++ sbin/savecore/savecore.c   9b2ddfc7e0e9cc66be409b0d1bf260b3e73e14bb
 @@ -697,7 +697,8 @@ find_dev(dev_t dev, int type)
                }
        }
        closedir(dfd);
 -      syslog(LOG_ERR, "can't find device %d/%d", major(dev), minor(dev));
 +      syslog(LOG_ERR, "can't find device %d/%d",
 +             (int)major(dev), (int)minor(dev));
        exit(1);
  }
  
 ============================================================
 --- sbin/swapctl/swapctl.c     95d49482037c4b9000c9e5d4ed72c35ea1186f19
 +++ sbin/swapctl/swapctl.c     ccca31e8de60261d8dfe6f8af2176f33b3b9f0bb
 @@ -523,7 +523,8 @@ get_dumpdev(void)
                if (name)
                        printf("%s\n", name);
                else
 -                      printf("major %d minor %d\n", major(dev), minor(dev));
 +                      printf("major %d minor %d\n",
 +                             (int)major(dev), (int)minor(dev));
        }
        return 1;
  }
 ============================================================
 --- sbin/sysctl/sysctl.c       036cac0343eeebc9d8c75e87a5f9b72403e52561
 +++ sbin/sysctl/sysctl.c       25ea00629bc01cc26ef9f607c73d16e4a43300cd
 @@ -2245,8 +2245,8 @@ kern_drivers(HANDLER_ARGS)
        if (!nflag)
                printf("%s%s", sname, eq);
        for (i = 0, sz /= sizeof(*kd); i < sz; i++) {
 -              (void)printf("%s[%d %d %s]", comma, kd[i].d_cmajor,
 -                  kd[i].d_bmajor, kd[i].d_name);
 +              (void)printf("%s[%d %d %s]", comma, (int)kd[i].d_cmajor,
 +                  (int)kd[i].d_bmajor, kd[i].d_name);
                comma = ", ";
        }
        (void)printf("\n");
 ============================================================
 --- sys/arch/i386/i386/dumpsys.c       e04c5ca64a9ccdea5581dbb45b6510e350214760
 +++ sys/arch/i386/i386/dumpsys.c       2b63e49e7d242aee98c2af57afa5107f6c5cf3e5
 @@ -169,12 +169,12 @@ dodumpsys(void)
        if (dumpsize == 0)
                cpu_dumpconf();
        if (dumplo <= 0 || dumpsize == 0) {
 -              printf("\ndump to dev %u,%u not possible\n", major(dumpdev),
 -                  minor(dumpdev));
 +              printf("\ndump to dev %u,%u not possible\n",
 +                  (unsigned)major(dumpdev), (unsigned)minor(dumpdev));
                return;
        }
 -      printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev),
 -          minor(dumpdev), dumplo);
 +      printf("\ndumping to dev %u,%u offset %ld\n",
 +          (unsigned)major(dumpdev), (unsigned)minor(dumpdev), dumplo);
  
        psize = (*bdev->d_psize)(dumpdev);
        printf("dump ");
 ============================================================
 --- sys/arch/i386/include/disklabel.h  cd1e20f93e9fc8ac7f34229abce7eb88d723852d
 +++ sys/arch/i386/include/disklabel.h  2fcbbc8a06e05734fce099fcfccc7f457dd7e6cb
 @@ -45,9 +45,10 @@
   * MAXPARTITIONS was increased.
   */
  #define __I386_MAXDISKS       ((1 << 20) / MAXPARTITIONS)
 -#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __I386_MAXDISKS)
 -#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \
 -    ((minor(dev) / (__I386_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS))
 +#define DISKUNIT(dev) \
 +    ((int)((minor(dev) / OLDMAXPARTITIONS) % __I386_MAXDISKS))
 +#define DISKPART(dev) ((int)((minor(dev) % OLDMAXPARTITIONS) + \
 +    ((minor(dev) / (__I386_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS)))
  #define       DISKMINOR(unit, part) \
      (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \
       ((part) / OLDMAXPARTITIONS) * (__I386_MAXDISKS * OLDMAXPARTITIONS))
 ============================================================
 --- sys/coda/coda_psdev.c      0bdb37d79e0fb91c068ebc9a40c3060ccdc043fe
 +++ sys/coda/coda_psdev.c      907c64255ea143a2cc0397da94318d2ee6daf23a
 @@ -238,7 +238,7 @@ vc_nb_close(dev_t dev, int flag, int mod
      err = dounmount(mi->mi_vfsp, flag, l);
      if (err)
        myprintf(("Error %d unmounting vfs in vcclose(%d)\n",
 -                 err, minor(dev)));
 +                 err, (int)minor(dev)));
      seldestroy(&vcp->vc_selproc);
      return 0;
  }
 ============================================================
 --- sys/dev/bluetooth/btuart.c cce0d5beb1580918dcc1507b72ba4135390ba43a
 +++ sys/dev/bluetooth/btuart.c 07dda4b8e5dec82f5d657f52c50f53a7b236be25
 @@ -261,7 +261,7 @@ btuartopen(dev_t devno __unused, struct 
        sc = device_private(dev);
  
        aprint_normal_dev(dev, "major %d minor %d\n",
 -          major(tp->t_dev), minor(tp->t_dev));
 +          (int)major(tp->t_dev), (int)minor(tp->t_dev));
  
        sc->sc_tp = tp;
        tp->t_sc = sc;
 ============================================================
 --- sys/dev/drm/drm_drv.c      ab4a9f3002c65e5f69fa4c8426d4bcd26f09e2d1
 +++ sys/dev/drm/drm_drv.c      836390e88fd8e0a1a288a20604f04f04a2b255c7
 @@ -816,7 +816,7 @@ drm_modcmd(modcmd_t cmd, void *arg)
  drm_modcmd(modcmd_t cmd, void *arg)
  {
  #ifdef _MODULE
 -      int bmajor = -1, cmajor = -1;
 +      devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
  
        switch (cmd) {
        case MODULE_CMD_INIT:
 ============================================================
 --- sys/dev/ir/irframe_tty.c   6892749f9d838206cfc388f104a3977fefd97595
 +++ sys/dev/ir/irframe_tty.c   d3c8379c99372262bed24ffb8641699166e31a63
 @@ -290,7 +290,7 @@ irframetopen(dev_t dev, struct tty *tp)
        tp->t_sc = sc;
        sc->sc_tp = tp;
        aprint_normal("%s attached at tty%02d\n", device_xname(d),
 -          minor(tp->t_dev));
 +          (int)minor(tp->t_dev));
  
        DPRINTF(("%s: set sc=%p\n", __func__, sc));
  
 @@ -330,7 +330,7 @@ irframetclose(struct tty *tp, int flag)
        if (sc != NULL) {
                tp->t_sc = NULL;
                aprint_normal("%s detached from tty%02d\n",
 -                  device_xname(sc->sc_irp.sc_dev), minor(tp->t_dev));
 +                  device_xname(sc->sc_irp.sc_dev), (int)minor(tp->t_dev));
  
                if (sc->sc_tp == tp) {
                        cfdata = device_cfdata(sc->sc_irp.sc_dev);
 ============================================================
 --- sys/dev/putter/putter.c    571708631d5e4377aa3690e49956d798117ded6a
 +++ sys/dev/putter/putter.c    87626ffc6dea77234796a8257daadcfeba25f8d9
 @@ -619,7 +619,7 @@ putter_modcmd(modcmd_t cmd, void *arg)
  putter_modcmd(modcmd_t cmd, void *arg)
  {
  #ifdef _MODULE
 -      int bmajor = -1, cmajor = -1;
 +      devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
  
        switch (cmd) {
        case MODULE_CMD_INIT:
 ============================================================
 --- sys/dev/usb/ucom.c 3b4fe8f2d4a5e5a68e803277a9ad21a30087cf1b
 +++ sys/dev/usb/ucom.c 67dbd6ad799aedbdb3add00fa853207556dce611
 @@ -83,9 +83,9 @@ int ucomdebug = 0;
  #define       UCOMDIALOUT_MASK        0x80000
  #define       UCOMCALLUNIT_MASK       0x40000
  
 -#define       UCOMUNIT(x)             (minor(x) & UCOMUNIT_MASK)
 -#define       UCOMDIALOUT(x)          (minor(x) & UCOMDIALOUT_MASK)
 -#define       UCOMCALLUNIT(x)         (minor(x) & UCOMCALLUNIT_MASK)
 +#define       UCOMUNIT(x)             ((int)(minor(x) & UCOMUNIT_MASK))
 +#define       UCOMDIALOUT(x)          ((int)(minor(x) & UCOMDIALOUT_MASK))
 +#define       UCOMCALLUNIT(x)         ((int)(minor(x) & UCOMCALLUNIT_MASK))
  
  struct ucom_softc {
        USBBASEDEVICE           sc_dev;         /* base device */
 ============================================================
 --- sys/dev/usb/ucycom.c       8b2eaa6371b48dd6c88b433323069d72e93851bf
 +++ sys/dev/usb/ucycom.c       e5555e71ccf4ec7b1d2d54046da27afeeaa2ee7e
 @@ -77,9 +77,9 @@ int  ucycomdebug = 0;
  #define UCYCOMDIALOUT_MASK    0x80000
  #define UCYCOMCALLUNIT_MASK   0x40000
  
 -#define UCYCOMUNIT(x)         (minor(x) & UCYCOMUNIT_MASK)
 -#define UCYCOMDIALOUT(x)      (minor(x) & UCYCOMDIALOUT_MASK)
 -#define UCYCOMCALLUNIT(x)     (minor(x) & UCYCOMCALLUNIT_MASK)
 +#define UCYCOMUNIT(x)         ((int)(minor(x) & UCYCOMUNIT_MASK))
 +#define UCYCOMDIALOUT(x)      ((int)(minor(x) & UCYCOMDIALOUT_MASK))
 +#define UCYCOMCALLUNIT(x)     ((int)(minor(x) & UCYCOMCALLUNIT_MASK))
  
  /* Configuration Byte */
  #define UCYCOM_RESET          0x80
 ============================================================
 --- sys/dev/usb/ugen.c 1b40e3ac92ea8cb3f82e314004c0233b8a993b14
 +++ sys/dev/usb/ugen.c 6e44243328f5c42c2d06b1510f048ba069a75bd4
 @@ -199,8 +199,8 @@ Static int ugen_get_alt_index(struct uge
  Static usbd_status ugen_set_interface(struct ugen_softc *, int, int);
  Static int ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx);
  
 -#define UGENUNIT(n) ((minor(n) >> 4) & 0xf)
 -#define UGENENDPOINT(n) (minor(n) & 0xf)
 +#define UGENUNIT(n) ((int)((minor(n) >> 4) & 0xf))
 +#define UGENENDPOINT(n) ((int)(minor(n) & 0xf))
  #define UGENDEV(u, e) (makedev(0, ((u) << 4) | (e)))
  
  USB_DECLARE_DRIVER(ugen);
 ============================================================
 --- sys/dev/usb/urio.c 52d9fd9bbb8c704e3c7d6cecb33a527e0a3d669a
 +++ sys/dev/usb/urio.c b412bc88d346e881b6b73ac81a46133a4055e0ab
 @@ -128,7 +128,7 @@ struct urio_softc {
        char                    sc_dying;
  };
  
 -#define URIOUNIT(n) (minor(n))
 +#define URIOUNIT(n) ((int)(minor(n)))
  
  #define URIO_RW_TIMEOUT 4000  /* ms */
  
 ============================================================
 --- sys/fs/msdosfs/msdosfs_vnops.c     9c0b2a88768dbf2d094f1d55ab4d6e0235c3a488
 +++ sys/fs/msdosfs/msdosfs_vnops.c     7c5f9a16e3c935f20006df6319513d36104b4b0c
 @@ -1818,7 +1818,8 @@ msdosfs_print(v)
        printf(
            "tag VT_MSDOSFS, startcluster %ld, dircluster %ld, diroffset %ld ",
            dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
 -      printf(" dev %d, %d ", major(dep->de_dev), minor(dep->de_dev));
 +      printf(" dev %d, %d ", (int)major(dep->de_dev),
 +                             (int)minor(dep->de_dev));
        printf("\n");
        return (0);
  }
 ============================================================
 --- sys/fs/ptyfs/ptyfs_vfsops.c        42849c8328079efc5f59a3ef131c721a46f87ddf
 +++ sys/fs/ptyfs/ptyfs_vfsops.c        677a2b01887cc016885838676d7ad5669ebab5a9
 @@ -136,7 +136,7 @@ ptyfs__makename(struct ptm_pty *pt, stru
                break;
        case 't':
                len = snprintf(tbuf, bufsiz, "%s/%d", ptyfs__getpath(l, mp),
 -                  minor(dev));
 +                  (int)minor(dev));
                break;
        default:
                return EINVAL;
 ============================================================
 --- sys/kern/kern_lkm.c        7da372c15e3e54b03c8ce3e833d0bad896c8e5da
 +++ sys/kern/kern_lkm.c        51e7ef76e4b60ae88d703f72e676cd8339c9b42c
 @@ -815,8 +815,8 @@ _lkm_dev(struct lkm_table *lkmtp, int cm
  
        case LKM_E_UNLOAD:
                devsw_detach(args->lkm_bdev, args->lkm_cdev);
 -              args->lkm_bdevmaj = -1;
 -              args->lkm_cdevmaj = -1;
 +              args->lkm_bdevmaj = NODEVMAJOR;
 +              args->lkm_cdevmaj = NODEVMAJOR;
                break;
  
        case LKM_E_STAT:        /* no special handling... */
 ============================================================
 --- sys/kern/subr_devsw.c      46fe7b32c25f0587ee7703dcdb7dd8871a61ad9e
 +++ sys/kern/subr_devsw.c      5c253b626e14162e48e4162002065a07bf555838
 @@ -99,8 +99,8 @@ extern int max_bdevsws, max_cdevsws, max
  extern const int sys_bdevsws, sys_cdevsws;
  extern int max_bdevsws, max_cdevsws, max_devsw_convs;
  
 -static int bdevsw_attach(const struct bdevsw *, int *);
 -static int cdevsw_attach(const struct cdevsw *, int *);
 +static int bdevsw_attach(const struct bdevsw *, devmajor_t *);
 +static int cdevsw_attach(const struct cdevsw *, devmajor_t *);
  static void devsw_detach_locked(const struct bdevsw *, const struct cdevsw *);
  
  void
 @@ -112,8 +112,9 @@ int
  }
  
  int
 -devsw_attach(const char *devname, const struct bdevsw *bdev, int *bmajor,
 -           const struct cdevsw *cdev, int *cmajor)
 +devsw_attach(const char *devname,
 +           const struct bdevsw *bdev, devmajor_t *bmajor,
 +           const struct cdevsw *cdev, devmajor_t *cmajor)
  {
        struct devsw_conv *conv;
        char *name;
 @@ -213,10 +214,11 @@ static int
  }
  
  static int
 -bdevsw_attach(const struct bdevsw *devsw, int *devmajor)
 +bdevsw_attach(const struct bdevsw *devsw, devmajor_t *devmajor)
  {
        const struct bdevsw **newptr;
 -      int bmajor, i;
 +      devmajor_t bmajor;
 +      int i;
  
        KASSERT(mutex_owned(&specfs_lock));
  
 @@ -262,10 +264,11 @@ static int
  }
  
  static int
 -cdevsw_attach(const struct cdevsw *devsw, int *devmajor)
 +cdevsw_attach(const struct cdevsw *devsw, devmajor_t *devmajor)
  {
        const struct cdevsw **newptr;
 -      int cmajor, i;
 +      devmajor_t cmajor;
 +      int i;
  
        KASSERT(mutex_owned(&specfs_lock));
  
 @@ -350,7 +353,7 @@ bdevsw_lookup(dev_t dev)
  const struct bdevsw *
  bdevsw_lookup(dev_t dev)
  {
 -      int bmajor;
 +      devmajor_t bmajor;
  
        if (dev == NODEV)
                return (NULL);
 @@ -369,7 +372,7 @@ cdevsw_lookup(dev_t dev)
  const struct cdevsw *
  cdevsw_lookup(dev_t dev)
  {
 -      int cmajor;
 +      devmajor_t cmajor;
  
        if (dev == NODEV)
                return (NULL);
 @@ -386,17 +389,17 @@ cdevsw_lookup(dev_t dev)
   * => Caller must ensure that the device is not detached, and therefore
   *    that the returned major is still valid when dereferenced.
   */
 -int
 +devmajor_t
  bdevsw_lookup_major(const struct bdevsw *bdev)
  {
 -      int bmajor;
 +      devmajor_t bmajor;
  
        for (bmajor = 0 ; bmajor < max_bdevsws ; bmajor++) {
                if (bdevsw[bmajor] == bdev)
                        return (bmajor);
        }
  
 -      return (-1);
 +      return (NODEVMAJOR);
  }
  
  /*
 @@ -405,17 +408,17 @@ bdevsw_lookup_major(const struct bdevsw 
   * => Caller must ensure that the device is not detached, and therefore
   *    that the returned major is still valid when dereferenced.
   */
 -int
 +devmajor_t
  cdevsw_lookup_major(const struct cdevsw *cdev)
  {
 -      int cmajor;
 +      devmajor_t cmajor;
  
        for (cmajor = 0 ; cmajor < max_cdevsws ; cmajor++) {
                if (cdevsw[cmajor] == cdev)
                        return (cmajor);
        }
  
 -      return (-1);
 +      return (NODEVMAJOR);
  }
  
  /*
 @@ -425,10 +428,11 @@ const char *
   *    that the name pointer is still valid when dereferenced.
   */
  const char *
 -devsw_blk2name(int bmajor)
 +devsw_blk2name(devmajor_t bmajor)
  {
        const char *name;
 -      int cmajor, i;
 +      devmajor_t cmajor;
 +      int i;
  
        name = NULL;
        cmajor = -1;
 @@ -457,14 +461,15 @@ devsw_blk2name(int bmajor)
   * => Caller must ensure that the device is not detached, and therefore
   *    that the major number is still valid when dereferenced.
   */
 -int
 +devmajor_t
  devsw_name2blk(const char *name, char *devname, size_t devnamelen)
  {
        struct devsw_conv *conv;
 -      int bmajor, i;
 +      devmajor_t bmajor;
 +      int i;
  
        if (name == NULL)
 -              return (-1);
 +              return (NODEVMAJOR);
  
        mutex_enter(&specfs_lock);
        for (i = 0 ; i < max_devsw_convs ; i++) {
 @@ -495,7 +500,7 @@ devsw_name2blk(const char *name, char *d
        }
  
        mutex_exit(&specfs_lock);
 -      return (-1);
 +      return (NODEVMAJOR);
  }
  
  /*
 @@ -504,14 +509,15 @@ devsw_name2blk(const char *name, char *d
   * => Caller must ensure that the device is not detached, and therefore
   *    that the major number is still valid when dereferenced.
   */
 -int
 +devmajor_t
  devsw_name2chr(const char *name, char *devname, size_t devnamelen)
  {
        struct devsw_conv *conv;
 -      int cmajor, i;
 +      devmajor_t cmajor;
 +      int i;
  
        if (name == NULL)
 -              return (-1);
 +              return (NODEVMAJOR);
  
        mutex_enter(&specfs_lock);
        for (i = 0 ; i < max_devsw_convs ; i++) {
 @@ -542,7 +548,7 @@ devsw_name2chr(const char *name, char *d
        }
  
        mutex_exit(&specfs_lock);
 -      return (-1);
 +      return (NODEVMAJOR);
  }
  
  /*
 @@ -554,11 +560,12 @@ devsw_chr2blk(dev_t cdev)
  dev_t
  devsw_chr2blk(dev_t cdev)
  {
 -      int bmajor, cmajor, i;
 +      devmajor_t bmajor, cmajor;
 +      int i;
        dev_t rv;
  
        cmajor = major(cdev);
 -      bmajor = -1;
 +      bmajor = NODEVMAJOR;
        rv = NODEV;
  
        mutex_enter(&specfs_lock);
 @@ -588,11 +595,12 @@ devsw_blk2chr(dev_t bdev)
  dev_t
  devsw_blk2chr(dev_t bdev)
  {
 -      int bmajor, cmajor, i;
 +      devmajor_t bmajor, cmajor;
 +      int i;
        dev_t rv;
  
        bmajor = major(bdev);
 -      cmajor = -1;
 +      cmajor = NODEVMAJOR;
        rv = NODEV;
  
        mutex_enter(&specfs_lock);
 ============================================================
 --- sys/kern/vfs_subr.c        6a0c432ead1a269ec6488d7b5e63e245b44055ec
 +++ sys/kern/vfs_subr.c        be6d2c963ad5a925f20867aae525b52e8769aba1
 @@ -2360,7 +2360,7 @@ vfs_mountroot(void)
                if (rootdev != NODEV)
                        panic("vfs_mountroot: rootdev set for DV_IFNET "
                            "(0x%08x -> %d,%d)", rootdev,
 -                          major(rootdev), minor(rootdev));
 +                          (int)major(rootdev), (int)minor(rootdev));
                break;
  
        case DV_DISK:
 ============================================================
 --- sys/miscfs/procfs/procfs_linux.c   71ce306dea8d1adbd054f6bb770a02599a143c2a
 +++ sys/miscfs/procfs/procfs_linux.c   5ce66353cc4fceec534de4c8d45f0bb796b1234e
 @@ -205,7 +205,8 @@ procfs_dodevices(struct lwp *curl, struc
                        continue;
  
                offset += snprintf(&bf[offset], LBFSZ - offset, 
 -                  "%3d %s\n", devsw_conv[i].d_cmajor, devsw_conv[i].d_name);
 +                  "%3d %s\n", (int)devsw_conv[i].d_cmajor,
 +                  devsw_conv[i].d_name);
                if (offset >= LBFSZ) {
                        mutex_exit(&specfs_lock);
                        goto out;
 @@ -224,7 +225,8 @@ procfs_dodevices(struct lwp *curl, struc
                        continue;
  
                offset += snprintf(&bf[offset], LBFSZ - offset, 
 -                  "%3d %s\n", devsw_conv[i].d_bmajor, devsw_conv[i].d_name);
 +                  "%3d %s\n", (int)devsw_conv[i].d_bmajor,
 +                  devsw_conv[i].d_name);
                if (offset >= LBFSZ) {
                        mutex_exit(&specfs_lock);
                        goto out;
 ============================================================
 --- sys/miscfs/procfs/procfs_map.c     570e0ca557efd9e50bb368a2227868c2d7452f75
 +++ sys/miscfs/procfs/procfs_map.c     60d7964fface0f1cb9172f7e915b745ed22085d5
 @@ -180,7 +180,7 @@ again:
                            (entry->etype & UVM_ET_COPYONWRITE) ? 'p' : 's',
                            (int)sizeof(void *) * 2,
                            (unsigned long)entry->offset,
 -                          major(dev), minor(dev), fileid, path);
 +                          (int)major(dev), (int)minor(dev), fileid, path);
                } else {
                        pos += snprintf(buffer + pos, bufsize - pos,
                            "0x%lx 0x%lx %c%c%c %c%c%c %s %s %d %d %d\n",
 ============================================================
 --- sys/miscfs/procfs/procfs_status.c  836feb45dfee84c18a9f6e828183d6f579a14549
 +++ sys/miscfs/procfs/procfs_status.c  29e062a25de4ecd275270623f2bebb152f08d803
 @@ -130,7 +130,7 @@ procfs_dostatus(
  
        if ((p->p_lflag & PL_CONTROLT) && (tp = sess->s_ttyp))
                ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%d,%d ",
 -                  major(tp->t_dev), minor(tp->t_dev));
 +                  (int)major(tp->t_dev), (int)minor(tp->t_dev));
        else
                ps += snprintf(ps, sizeof(psbuf) - (ps - psbuf), "%d,%d ",
                    -1, -1);
 ============================================================
 --- sys/miscfs/specfs/spec_vnops.c     987fd41994205020c8a3b9ce508b87a2b0e8c2a7
 +++ sys/miscfs/specfs/spec_vnops.c     56dc705e3b86b79ddaf359774635d9843ec30e46
 @@ -1000,8 +1000,8 @@ spec_print(void *v)
                struct vnode *a_vp;
        } */ *ap = v;
  
 -      printf("dev %d, %d\n", major(ap->a_vp->v_rdev),
 -          minor(ap->a_vp->v_rdev));
 +      printf("dev %d, %d\n", (int)major(ap->a_vp->v_rdev),
 +          (int)minor(ap->a_vp->v_rdev));
        return 0;
  }
  
 ============================================================
 --- sys/rump/librump/rumpkern/emul.c   e22dbcab5925085eadab2cb42f40ce301b871f2b
 +++ sys/rump/librump/rumpkern/emul.c   d3a11191bb5ec6a6fc8c79d0e42d98a74039979f
 @@ -593,8 +593,9 @@ int
  }
  
  int
 -devsw_attach(const char *devname, const struct bdevsw *bdev, int *bmajor,
 -      const struct cdevsw *cdev, int *cmajor)
 +devsw_attach(const char *devname,
 +      const struct bdevsw *bdev, devmajor_t *bmajor,
 +      const struct cdevsw *cdev, devmajor_t *cmajor)
  {
  
        panic("%s: not implemented", __func__);
 ============================================================
 --- sys/sys/conf.h     9f05263f4a8dca129073ed13d7ec642ca0282bd4
 +++ sys/sys/conf.h     ef42f81b6f1a9e31c85343075490e854ed5d4cb2
 @@ -94,13 +94,13 @@ struct cdevsw {
  
  #ifdef _KERNEL
  
 -int devsw_attach(const char *, const struct bdevsw *, int *,
 -               const struct cdevsw *, int *);
 +int devsw_attach(const char *, const struct bdevsw *, devmajor_t *,
 +               const struct cdevsw *, devmajor_t *);
  int devsw_detach(const struct bdevsw *, const struct cdevsw *);
  const struct bdevsw *bdevsw_lookup(dev_t);
  const struct cdevsw *cdevsw_lookup(dev_t);
 -int bdevsw_lookup_major(const struct bdevsw *);
 -int cdevsw_lookup_major(const struct cdevsw *);
 +devmajor_t bdevsw_lookup_major(const struct bdevsw *);
 +devmajor_t cdevsw_lookup_major(const struct cdevsw *);
  
  #define       dev_type_open(n)        int n (dev_t, int, int, struct lwp *)
  #define       dev_type_close(n)       int n (dev_t, int, int, struct lwp *)
 @@ -228,15 +228,15 @@ struct devsw_conv {
  
  struct devsw_conv {
        const char *d_name;
 -      int d_bmajor;
 -      int d_cmajor;
 +      devmajor_t d_bmajor;
 +      devmajor_t d_cmajor;
  };
  
  #ifdef _KERNEL
  void devsw_init(void);
 -const char *devsw_blk2name(int);
 -int devsw_name2blk(const char *, char *, size_t);
 -int devsw_name2chr(const char *, char *, size_t);
 +const char *devsw_blk2name(devmajor_t);
 +devmajor_t devsw_name2blk(const char *, char *, size_t);
 +devmajor_t devsw_name2chr(const char *, char *, size_t);
  dev_t devsw_chr2blk(dev_t);
  dev_t devsw_blk2chr(dev_t);
  #endif /* _KERNEL */
 ============================================================
 --- sys/sys/lkm.h      6597d155f42f6c77319327957b06a3bbaace2ecb
 +++ sys/sys/lkm.h      a1fcead5171777292c5375bf24fe169b0c56b7c2
 @@ -116,9 +116,9 @@ struct lkm_dev {
        struct lkm_any mod;
        const char *lkm_devname;
        const struct bdevsw     *lkm_bdev;
 -      int lkm_bdevmaj;
 +      devmajor_t lkm_bdevmaj;
        const struct cdevsw     *lkm_cdev;
 -      int lkm_cdevmaj;
 +      devmajor_t lkm_cdevmaj;
  };
  
  #ifdef STREAMS
 ============================================================
 --- sys/sys/sysctl.h   70cfbed5be95f2268ab2be24dcb86c4304733797
 +++ sys/sys/sysctl.h   12c5dd129939eeec3eb419d3dccd8072c2792911
 @@ -711,8 +711,8 @@ struct kinfo_drivers {
   */
  
  struct kinfo_drivers {
 -      int32_t         d_cmajor;
 -      int32_t         d_bmajor;
 +      devmajor_t      d_cmajor;
 +      devmajor_t      d_bmajor;
        char            d_name[24];
  };
  
 ============================================================
 --- sys/sys/types.h    503eb280f263bd5991da2f1e0ce5b8461173217c
 +++ sys/sys/types.h    2e2ad9a573f9931aa1538ded25ed2d238208a739
 @@ -258,8 +258,11 @@ __END_DECLS
  
  #if defined(_NETBSD_SOURCE)
  /* Major, minor numbers, dev_t's. */
 -#define       major(x)        ((int32_t)((((x) & 0x000fff00) >>  8)))
 -#define       minor(x)        ((int32_t)((((x) & 0xfff00000) >> 12) | \
 +typedef long devmajor_t, devminor_t;
 +#define NODEVMAJOR (-1)
 +#define NODEVMINOR (-1)
 +#define       major(x)        ((devmajor_t)((((x) & 0x000fff00) >>  8)))
 +#define       minor(x)        ((devminor_t)((((x) & 0xfff00000) >> 12) | \
                                   (((x) & 0x000000ff) >>  0)))
  #define       makedev(x,y)    ((dev_t)((((x) <<  8) & 0x000fff00) | \
                                 (((y) << 12) & 0xfff00000) | \
 ============================================================
 --- sys/ufs/ufs/ufs_vnops.c    e4d899b383a7e3ab8152e2e15fdce9dab743d78d
 +++ sys/ufs/ufs/ufs_vnops.c    3fbaf68f82a258beafb9c0168a5585c92c7e1a2b
 @@ -1973,7 +1973,7 @@ ufs_print(void *v)
        ip = VTOI(vp);
        printf("tag VT_UFS, ino %llu, on dev %d, %d",
            (unsigned long long)ip->i_number,
 -          major(ip->i_dev), minor(ip->i_dev));
 +          (int)major(ip->i_dev), (int)minor(ip->i_dev));
        printf(" flags 0x%x, effnlink %d, nlink %d\n",
            ip->i_flag, ip->i_ffs_effnlink, ip->i_nlink);
        printf("\tmode 0%o, owner %d, group %d, size %qd",
 ============================================================
 --- usr.bin/config/mkswap.c    98416979e8289eb0b8e0555c39b293924855a3eb
 +++ usr.bin/config/mkswap.c    f462d4f1d4a867352103f73fcaabfa1bcd83cc59
 @@ -80,7 +80,7 @@ mkdevstr(dev_t d)
                (void)snprintf(buf, sizeof(buf), "NODEV");
        else
                (void)snprintf(buf, sizeof(buf), "makedev(%d, %d)",
 -                  major(d), minor(d));
 +                  (int)major(d), (int)minor(d));
        return buf;
  }
  
 ============================================================
 --- usr.bin/find/ls.c  411221adb5efd443747ccb835664ced79fada33c
 +++ usr.bin/find/ls.c  f26ca3f4443143ab3d6b1cfd30ca0bccd6b19939
 @@ -75,8 +75,8 @@ printlong(char *name,                        /* filename to p
            group_from_gid(sb->st_gid, 0));
  
        if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode))
 -              (void)printf("%3d,%5d ", major(sb->st_rdev),
 -                  minor(sb->st_rdev));
 +              (void)printf("%3d,%5d ", (int)major(sb->st_rdev),
 +                  (int)minor(sb->st_rdev));
        else
                (void)printf("%9lld ", (long long)sb->st_size);
        printtime(sb->st_mtime);
 ============================================================
 --- usr.bin/fstat/fstat.c      83047e00f8d77d84a32a7d8a5d76af18fcfee51f
 +++ usr.bin/fstat/fstat.c      c9ae79433db982c56ea45740ed5001c5e4ff9bc1
 @@ -510,7 +510,8 @@ vtrans(struct vnode *vp, int i, int flag
                return;
        }
        if (nflg)
 -              (void)printf(" %2d,%-2d", major(fst.fsid), minor(fst.fsid));
 +              (void)printf(" %2d,%-2d",
 +                           (int)major(fst.fsid), (int)minor(fst.fsid));
        else
                (void)printf(" %-8s", getmnton(vn.v_mount));
        if (nflg)
 @@ -525,8 +526,8 @@ vtrans(struct vnode *vp, int i, int flag
  
                if (nflg || ((name = devname(fst.rdev, vn.v_type == VCHR ? 
                    S_IFCHR : S_IFBLK)) == NULL))
 -                      (void)printf("  %2d,%-2d", major(fst.rdev),
 -                          minor(fst.rdev));
 +                      (void)printf("  %2d,%-2d", (int)major(fst.rdev),
 +                          (int)minor(fst.rdev));
                else
                        (void)printf(" %6s", name);
                break;
 ============================================================
 --- usr.bin/pmap/pmap.c        5851f54fab2c311b4e656168247212cb98ec82c4
 +++ usr.bin/pmap/pmap.c        42b8e50691cc55bc9e7ff3db7b4cc552f26855c1
 @@ -399,8 +399,9 @@ dump_vm_map_entry(kvm_t *kd, struct kinf
                       vme->advice);
                if (verbose) {
                        if (inode)
 -                              printf(" %u,%u %llu", major(dev), minor(dev),
 -                                  (unsigned long long)inode);
 +                              printf(" %u,%u %llu",
 +                                (unsigned)major(dev), (unsigned)minor(dev),
 +                                (unsigned long long)inode);
                        if (name[0])
                                printf(" %s", name);
                }
 @@ -418,7 +419,8 @@ dump_vm_map_entry(kvm_t *kd, struct kinf
                       UVM_ET_ISCOPYONWRITE(vme) ? 'p' : 's',
                       (int)sizeof(void *) * 2,
                       vme->offset,
 -                     major(dev), minor(dev), (unsigned long long)inode,
 +                     (int)major(dev), (int)minor(dev),
 +                     (unsigned long long)inode,
                       (name[0] != ' ') || verbose ? name : "");
        }
  
 @@ -440,7 +442,8 @@ dump_vm_map_entry(kvm_t *kd, struct kinf
                        printf("\t%*s", indent(2), "");
                        if (inode)
                                printf("(dev=%u,%u ino=%llu [%s] [%p])\n",
 -                                  major(dev), minor(dev),
 +                                  (unsigned)major(dev),
 +                                  (unsigned)minor(dev),
                                    (unsigned long long)inode, name, P(vp));
                        else if (name[0] == ' ')
                                printf("(%s)\n", &name[2]);
 @@ -496,7 +499,8 @@ dump_vm_map_entry(kvm_t *kd, struct kinf
                       vme->inheritance,
                       vme->wired_count,
                       vme->advice,
 -                     major(dev), minor(dev), (unsigned long long)inode,
 +                     (unsigned)major(dev), (unsigned)minor(dev),
 +                     (unsigned long long)inode,
                       name, P(vp));
        }
  
 @@ -709,7 +713,7 @@ findname(kvm_t *kd, struct kbit *vmspace
                                snprintf(buf, sizeof(buf), "/dev/%s", name);
                        else
                                snprintf(buf, sizeof(buf), "  [ device %d,%d ]",
 -                                       major(dev), minor(dev));
 +                                       (int)major(dev), (int)minor(dev));
                        name = buf;
                }
                else if (UVM_OBJ_IS_AOBJ(D(uvm_obj, uvm_object))) 
 ============================================================
 --- usr.sbin/pstat/pstat.c     1f05e323bee6ea69abdca46a727f264c623c97ef
 +++ usr.sbin/pstat/pstat.c     337e13e2e0e861cda05f23769824d402db467def
 @@ -497,7 +497,7 @@ ufs_print(struct vnode *vp, int ovflw)
                if (usenumflag ||
                    (name = devname(rdev, type)) == NULL) {
                        snprintf(dev, sizeof(dev), "%d,%d",
 -                          major(rdev), minor(rdev));
 +                          (int)major(rdev), (int)minor(rdev));
                        name = dev;
                }
                PRWORD(ovflw, " %*s", 8, 1, name);
 @@ -532,7 +532,8 @@ ext2fs_print(struct vnode *vp, int ovflw
                if (usenumflag ||
                    (name = devname(dip.e2di_rdev, type)) == NULL) {
                        snprintf(dev, sizeof(dev), "%d,%d",
 -                          major(dip.e2di_rdev), minor(dip.e2di_rdev));
 +                          (int)major(dip.e2di_rdev),
 +                          (int)minor(dip.e2di_rdev));
                        name = dev;
                }
                PRWORD(ovflw, " %*s", 8, 1, name);
 @@ -585,7 +586,7 @@ nfs_print(struct vnode *vp, int ovflw)
        device:
                if (usenumflag || (name = devname(va.va_rdev, type)) == NULL) {
                        (void)snprintf(dev, sizeof(dev), "%d,%d",
 -                          major(va.va_rdev), minor(va.va_rdev));
 +                          (int)major(va.va_rdev), (int)minor(va.va_rdev));
                        name = dev;
                }
                PRWORD(ovflw, " %*s", 8, 1, name);
 @@ -789,7 +790,7 @@ ttyprt(struct tty *tp)
  
        if (usenumflag || (name = devname(tp->t_dev, S_IFCHR)) == NULL) {
                (void)snprintf(dev, sizeof(dev), "0x%3x:%x",
 -                  major(tp->t_dev), minor(tp->t_dev));
 +                  (int)major(tp->t_dev), (int)minor(tp->t_dev));
                name = dev;
        }
        ovflw = 0;
 ============================================================
 --- usr.sbin/vnconfig/vnconfig.c       6de02be5c5ee0b5cf24f443097c15aa566fa6914
 +++ usr.sbin/vnconfig/vnconfig.c       31b03a9f83cdd5697f4423aa502fda27414978fa
 @@ -259,8 +259,8 @@ main(argc, argv)
                                        printf("%s ", dev);
                                else
                                        printf("dev %d,%d ",
 -                                          major(vnu.vnu_dev),
 -                                          minor(vnu.vnu_dev));
 +                                          (int)major(vnu.vnu_dev),
 +                                          (int)minor(vnu.vnu_dev));
  
                                printf("inode %llu\n",
                                    (unsigned long long)vnu.vnu_ino);
 
 --==_Exmh_10139695340550--
 


Home | Main Index | Thread Index | Old Index