diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 325c7ef51def..43c026ce0b07 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 377d90a17c25..156a192d0d17 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 377d90a17c25..156a192d0d17 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));