From b8e49f681ba1043f50d42c84eb3eeb78a6d8e96e Mon Sep 17 00:00:00 2001 From: Bill Fumerola Date: Tue, 17 Aug 1999 20:25:50 +0000 Subject: [PATCH] Welcome devtoname(), to most likely be used when printing information about a dev_t. printf("%x", dev) now becomes printf("%s", devtoname(dev)) because printing actual information about the device is much more useful then printing a pointer to an address that would never help the developer debug. Submitted by: phk, bde --- sys/cam/scsi/scsi_pt.c | 4 ++-- sys/dev/speaker/spkr.c | 10 +++++----- sys/i386/isa/spkr.c | 10 +++++----- sys/kern/kern_conf.c | 9 ++++++++- sys/sys/conf.h | 3 ++- sys/sys/linedisc.h | 3 ++- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c index e015c36426a2..77dea1331b4c 100644 --- a/sys/cam/scsi/scsi_pt.c +++ b/sys/cam/scsi/scsi_pt.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_pt.c,v 1.9 1999/05/30 16:51:05 phk Exp $ + * $Id: scsi_pt.c,v 1.10 1999/05/31 11:24:07 phk Exp $ */ #include @@ -159,7 +159,7 @@ ptopen(dev_t dev, int flags, int fmt, struct proc *p) } CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, - ("ptopen: dev=0x%x (unit %d)\n", dev, unit)); + ("ptopen: dev=%s (unit %d)\n", devtoname(dev), unit)); if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) { splx(s); diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index f594b8bb8907..f6302a328e47 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -4,7 +4,7 @@ * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993 * modified for FreeBSD by Andrew A. Chernov * - * $Id: spkr.c,v 1.36 1999/05/30 16:52:27 phk Exp $ + * $Id: spkr.c,v 1.37 1999/05/31 11:26:32 phk Exp $ */ #include "speaker.h" @@ -480,7 +480,7 @@ spkropen(dev, flags, fmt, p) struct proc *p; { #ifdef DEBUG - (void) printf("spkropen: entering with dev = %x\n", dev); + (void) printf("spkropen: entering with dev = %s\n", devtoname(dev)); #endif /* DEBUG */ if (minor(dev) != 0) @@ -506,8 +506,8 @@ spkrwrite(dev, uio, ioflag) int ioflag; { #ifdef DEBUG - printf("spkrwrite: entering with dev = %x, count = %d\n", - dev, uio->uio_resid); + printf("spkrwrite: entering with dev = %s, count = %d\n", + devtoname(dev), uio->uio_resid); #endif /* DEBUG */ if (minor(dev) != 0) @@ -539,7 +539,7 @@ spkrclose(dev, flags, fmt, p) struct proc *p; { #ifdef DEBUG - (void) printf("spkrclose: entering with dev = %x\n", dev); + (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev)); #endif /* DEBUG */ if (minor(dev) != 0) diff --git a/sys/i386/isa/spkr.c b/sys/i386/isa/spkr.c index f594b8bb8907..f6302a328e47 100644 --- a/sys/i386/isa/spkr.c +++ b/sys/i386/isa/spkr.c @@ -4,7 +4,7 @@ * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993 * modified for FreeBSD by Andrew A. Chernov * - * $Id: spkr.c,v 1.36 1999/05/30 16:52:27 phk Exp $ + * $Id: spkr.c,v 1.37 1999/05/31 11:26:32 phk Exp $ */ #include "speaker.h" @@ -480,7 +480,7 @@ spkropen(dev, flags, fmt, p) struct proc *p; { #ifdef DEBUG - (void) printf("spkropen: entering with dev = %x\n", dev); + (void) printf("spkropen: entering with dev = %s\n", devtoname(dev)); #endif /* DEBUG */ if (minor(dev) != 0) @@ -506,8 +506,8 @@ spkrwrite(dev, uio, ioflag) int ioflag; { #ifdef DEBUG - printf("spkrwrite: entering with dev = %x, count = %d\n", - dev, uio->uio_resid); + printf("spkrwrite: entering with dev = %s, count = %d\n", + devtoname(dev), uio->uio_resid); #endif /* DEBUG */ if (minor(dev) != 0) @@ -539,7 +539,7 @@ spkrclose(dev, flags, fmt, p) struct proc *p; { #ifdef DEBUG - (void) printf("spkrclose: entering with dev = %x\n", dev); + (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev)); #endif /* DEBUG */ if (minor(dev) != 0) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 7be808ea6bc6..a372fb9e18f1 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_conf.c,v 1.56 1999/08/13 10:29:20 phk Exp $ + * $Id: kern_conf.c,v 1.57 1999/08/15 09:32:47 phk Exp $ */ #include @@ -309,3 +309,10 @@ make_dev(struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char return (dev); } +char * +devtoname(dev_t dev) +{ + + return (dev->si_name); +} + diff --git a/sys/sys/conf.h b/sys/sys/conf.h index a5e8ab6bc1c9..73b3600b147d 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)conf.h 8.5 (Berkeley) 1/9/95 - * $Id: conf.h,v 1.73 1999/08/14 11:40:49 phk Exp $ + * $Id: conf.h,v 1.74 1999/08/15 09:32:44 phk Exp $ */ #ifndef _SYS_CONF_H_ @@ -263,6 +263,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)); int iskmemdev __P((dev_t dev)); int iszerodev __P((dev_t dev)); dev_t makebdev __P((int maj, int min)); diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index a5e8ab6bc1c9..73b3600b147d 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)conf.h 8.5 (Berkeley) 1/9/95 - * $Id: conf.h,v 1.73 1999/08/14 11:40:49 phk Exp $ + * $Id: conf.h,v 1.74 1999/08/15 09:32:44 phk Exp $ */ #ifndef _SYS_CONF_H_ @@ -263,6 +263,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)); int iskmemdev __P((dev_t dev)); int iszerodev __P((dev_t dev)); dev_t makebdev __P((int maj, int min));