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



dholland%eecs.harvard.edu@localhost said:
> Probably changing major() (and minor(), for symmetry) to produce an
> unsigned value

The kernel is using int for majors and minors, and is using -1
as special value. I'd say we should adjust getdevmajor() - it
is NetBSD specific and used at only one place in the tree.
(and the error check against ~0 is ugly)
I've just done a full build with the appended patch - would that
work for you?

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
-------------------------------------------------------------------
-------------------------------------------------------------------
#
# old_revision [bc9b40deb2273f24a32fed91af7d896bc85babaf]
#
# patch "include/stdlib.h"
#  from [88c992035e9fc9a987d6bbd51ed517126c84252c]
#    to [59cc802a461f4ad8962ff41d4c6490ca1d2d577a]
# 
# patch "lib/libc/gen/devname.c"
#  from [fc188811536b897bb2cfaeefea452b85edef7fd4]
#    to [a5c8cbb829ced66efa70d7881296e90962a03ba5]
# 
# patch "lib/libc/gen/getdevmajor.c"
#  from [8d741a93bb4ddb0f918f7da5ef4c54b8c9d10141]
#    to [d8e74dcdc59b115a68d3d7368c9131a3e388c422]
#
============================================================
--- include/stdlib.h    88c992035e9fc9a987d6bbd51ed517126c84252c
+++ include/stdlib.h    59cc802a461f4ad8962ff41d4c6490ca1d2d577a
@@ -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);
+int     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      a5c8cbb829ced66efa70d7881296e90962a03ba5
@@ -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 int pts = -2;
 
        if (!db && !failure &&
            !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) {
@@ -165,9 +165,9 @@ 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 != -1 && major(dev) == pts) {
                                (void)snprintf(ptr->name, sizeof(ptr->name),
                                    "%s%d", _PATH_DEV_PTS +
                                    sizeof(_PATH_DEV) - 1, minor(dev));
============================================================
--- lib/libc/gen/getdevmajor.c  8d741a93bb4ddb0f918f7da5ef4c54b8c9d10141
+++ lib/libc/gen/getdevmajor.c  d8e74dcdc59b115a68d3d7368c9131a3e388c422
@@ -51,13 +51,13 @@ __weak_alias(getdevmajor,_getdevmajor)
 __weak_alias(getdevmajor,_getdevmajor)
 #endif
 
-dev_t
+int
 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;
+       int n = -1;
 
        if (type != S_IFCHR && type != S_IFBLK) {
                errno = EINVAL;


Home | Main Index | Thread Index | Old Index