As a result of a discussion between myself, Bruce Evans, and Poul-Henning
Kemp, there now exists a kernel function:

char *devtoname (dev_t dev)

Use it like so:

printf("dev: %s", devtoname(dev));

Intead of the previous:

printf("dev: %x", dev);

Using the old format will only print a pointer that will be of no use
after an error has occured. Developers who are using a debugger wouldn't
need this debug message anyways, so the memory address is of use to no-one.

Examples of how to fix existing code has been committed in cam/scsi/scsi_pt.c
and i386/isa/spkr.c, though I'm sure there exists a plethora of old code
which uses the old style.

The function was written by phk.

-- 
- bill fumerola - [EMAIL PROTECTED] - BF1560 - computer horizons corp -
- ph:(800) 252-2421 - [EMAIL PROTECTED] - [EMAIL PROTECTED]  -

---------- Forwarded message ----------
Date: Wed, 18 Aug 1999 08:48:08 +0930
From: Greg Lehey <[EMAIL PROTECTED]>
To: Bill Fumerola <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: HEADS UP: devtoname (was: cvs commit: src/sys/cam/scsi scsi_pt.c
    src/sys/sys conf.h src/sys/i386/isa spkr.c src/sys/kern kern_conf.c)

On Tuesday, 17 August 1999 at 13:25:51 -0700, Bill Fumerola wrote:
> billf       1999/08/17 13:25:50 PDT
>
>   Modified files:
>     sys/cam/scsi         scsi_pt.c
>     sys/sys              conf.h
>     sys/i386/isa         spkr.c
>     sys/kern             kern_conf.c
>   Log:
>   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.

This is nice stuff.  I think it's worth a heads up.  It's far too easy
to miss this kind of thing in the daily flood of updated $Id$ strings.

Greg
--
See complete headers for address, home page and phone numbers
finger [EMAIL PROTECTED] for PGP public key




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to