[OpenAFS-devel] [PATCH] flexelint: fun with printf

George Talbot gtalbot@locuspharma.com
01 Dec 2003 11:02:10 -0500


ptrdiff_t is guaranteed by C99 (99, right?) to be the width of a
pointer.

--George

On Mon, 2003-12-01 at 10:10, Ted Anderson wrote:
> On 11/21/2003 14:45, Joe Buehler wrote:
> > This patch addresses a number of problems with printf-like functions.
> 
> I don't know how the gatekeepers feel about this recent spate of 
> patches, but it seems like a valuable and overdue effort.  Thanks.
> 
> > Most of them are %x formats applied to pointers (which could be a
> > problem depending on the architecture I would assume).  There is a
> > %p format for pointers on many machines but I don't know if it
> > applies to all supported OpenAFS platforms so I didn't go that route.
> 
>  > -	afsi_log("osi_LogCreate log addr %x", afsd_logp);
>  > +	afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
> 
> I think it would be more correct, and still portable, to use long 
> instead of int to represent pointers.  I don't know it C mandates it, 
> but I think the wide-spread convention is that longs are at least as big 
> as pointers, while the size of ints vary more widely.  So this would 
> lead to code like this:
> 
> 	afsi_log("osi_LogCreate log addr %lx", (long)afsd_logp);
> 
> Ted Anderson
> 
> 
> _______________________________________________
> OpenAFS-devel mailing list
> OpenAFS-devel@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-devel