Const'ify devtoname() and d_name. This exposes some errors (2 non-benign).

Handle negative minor numbers properly in devtoname().
This commit is contained in:
Bruce Evans 1999-09-13 12:29:32 +00:00
parent 8dc47ef606
commit c32cc1493f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51225
3 changed files with 11 additions and 7 deletions

View File

@ -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);
}

View File

@ -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));

View File

@ -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));