Messages in this thread | | | Date | Fri, 15 Feb 2002 15:37:17 -0600 | From | Troy Benjegerdes <> | Subject | Re: [patch] printk and dma_addr_t |
| |
On Wed, Feb 13, 2002 at 02:26:46AM -0800, Andrew Morton wrote: > Alan Cox wrote: > > > > So how do they modify the printf format rules in gcc ? > > Good question. It'd be nice for NIPQUAD and such. > > Here's an alternative fix. Less vomitous? > > Sorry about sticking a prototype in types.h. It needs to be > somewhere where all dma_addr_t users will see it, and where > dma_addr_t is already in scope. Maybe there's a better place?
Personally, I like this less.. I don't think the previous #define DMA_ADDR_T_FMT (or whatever it was) is that bad, considering the options.
Once we set the precedent of having little 'char * form_some_random_type()' functions, they will show up all over the place.
I need something like this for the MTD patch I've got that supports 64 bit buswidths on 32 bit machines and needs to printk the data on error.
I found that #define CFI_FMT '%lx' or whatever to be more straightforward, and easier to understand.
> + */ > +char *form_dma_addr_t(char *buf, dma_addr_t a) > +{ > + char *fmt; /* Funny code to prevent a printf warning */ > + > + if (sizeof(dma_addr_t) == sizeof(long)) > + fmt = "%lx"; > + else > + fmt = "%Lx"; > + > + sprintf(buf, fmt, a); > + return buf; > +}
-- Troy Benjegerdes | master of mispeeling | 'da hozer' | hozer@drgw.net -----"If this message isn't misspelled, I didn't write it" -- Me ----- "Why do musicians compose symphonies and poets write poems? They do it because life wouldn't have any meaning for them if they didn't. That's why I draw cartoons. It's my life." -- Charles Schulz - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |