diff options
author | bde <bde@FreeBSD.org> | 1999-09-13 12:29:32 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1999-09-13 12:29:32 +0000 |
commit | 5fbd95466cc7159018fb8d55864a955373bffd97 (patch) | |
tree | 36f60d2dec419534015d1d1e9f893de74b993e6a /sys | |
parent | ad7d5e0e01aad87115442a7aac072c1ff28f34bd (diff) | |
download | FreeBSD-src-5fbd95466cc7159018fb8d55864a955373bffd97.zip FreeBSD-src-5fbd95466cc7159018fb8d55864a955373bffd97.tar.gz |
Const'ify devtoname() and d_name. This exposes some errors (2 non-benign).
Handle negative minor numbers properly in devtoname().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_conf.c | 10 | ||||
-rw-r--r-- | sys/sys/conf.h | 4 | ||||
-rw-r--r-- | sys/sys/linedisc.h | 4 |
3 files changed, 11 insertions, 7 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 325c7ef..43c026c 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -357,10 +357,11 @@ remove_dev(dev_t dev) freedev(dev); } -char * +const char * devtoname(dev_t dev) { char *p; + int mynor; if (dev->si_name[0] == '#' || dev->si_name[0] == '\0') { p = dev->si_name; @@ -369,8 +370,11 @@ devtoname(dev_t dev) else sprintf(p, "#%d/", major(dev)); p += strlen(p); - sprintf(p, minor(dev) > 255 ? "0x%x" : "%d", minor(dev)); + mynor = minor(dev); + if (mynor < 0 || mynor > 255) + sprintf(p, "%#x", (u_int)mynor); + else + sprintf(p, "%d", mynor); } return (dev->si_name); } - diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 377d90a..156a192 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -176,7 +176,7 @@ struct cdevsw { d_poll_t *d_poll; d_mmap_t *d_mmap; d_strategy_t *d_strategy; - char *d_name; /* base device name, e.g. 'vn' */ + const char *d_name; /* base device name, e.g. 'vn' */ d_parms_t *d_bogoparms; /* XXX not used */ int d_maj; d_dump_t *d_dump; @@ -280,7 +280,7 @@ int cdevsw_remove __P((struct cdevsw *old)); dev_t chrtoblk __P((dev_t dev)); struct cdevsw *devsw __P((dev_t dev)); int devsw_module_handler __P((struct module *mod, int what, void *arg)); -char *devtoname __P((dev_t dev)); +const char *devtoname __P((dev_t dev)); void freedev __P((dev_t dev)); int iskmemdev __P((dev_t dev)); int iszerodev __P((dev_t dev)); diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 377d90a..156a192 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -176,7 +176,7 @@ struct cdevsw { d_poll_t *d_poll; d_mmap_t *d_mmap; d_strategy_t *d_strategy; - char *d_name; /* base device name, e.g. 'vn' */ + const char *d_name; /* base device name, e.g. 'vn' */ d_parms_t *d_bogoparms; /* XXX not used */ int d_maj; d_dump_t *d_dump; @@ -280,7 +280,7 @@ int cdevsw_remove __P((struct cdevsw *old)); dev_t chrtoblk __P((dev_t dev)); struct cdevsw *devsw __P((dev_t dev)); int devsw_module_handler __P((struct module *mod, int what, void *arg)); -char *devtoname __P((dev_t dev)); +const char *devtoname __P((dev_t dev)); void freedev __P((dev_t dev)); int iskmemdev __P((dev_t dev)); int iszerodev __P((dev_t dev)); |