Re: The great alpha compile warning hunt

Sean Hunter (sean@uncarved.co.uk)
Sat, 24 Jul 1999 07:51:12 +0100


On Fri, Jul 23, 1999 at 08:35:41PM -0400, Albert D. Cahalan wrote:
> You cast to an unsigned int: (unsigned)sizeof(foo)

I don't think this is the right way. Either you keep the full 64
bits, or you lose valuable debugging info that the printk was put
there to tell you. In the short term I've done a lot of casts to long
(thanks to Alan Modra, Jeff Garzik et al), and also submitted a patch
which allows printk to work with size_t's without the cast at all, by
using "%zd" et al. I think this is the best way all round.

>
> This is not good. Every printk() with the problem ends up with
> an extra character in the format string and possibly extra overhead.

Firstly, I don't think "printk" latency is a real performance
issue (also my patch doesn't add overhead). Secondly, I don't think
an extra character in the format string is a loss compared with doing
a lot of explicit casts that are pretty ugly, and could (if done
wrong) lose information. Besides anything else, putting "%zd" means
"I am aware of portability, this is a size_t", which is a valuable
contribution to keeping the code self_documenting IMO.

Thanks for the comments though.

Sean

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/