[OpenAFS-devel] [PATCH] flexelint: fun with printf
Joerg Sonnenberger
joerg@britannica.bec.de
Mon, 1 Dec 2003 18:22:27 +0100
On Mon, Dec 01, 2003 at 10:10:55AM -0500, 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);
What about:
afsi_log("osi_LogCreate log addr %p", (void*)afsd_logp);
The BSD man page doesn't mention %p as non portable, so it may be the
correct way.
Joerg
>
> Ted Anderson
>
>
> _______________________________________________
> OpenAFS-devel mailing list
> OpenAFS-devel@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-devel
>