linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How do I printk <type> correctly?
@ 2008-10-23 11:41 Alexey Dobriyan
  2008-10-23 11:51 ` David John
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Alexey Dobriyan @ 2008-10-23 11:41 UTC (permalink / raw)
  To: linux-kernel

If variable is of Type	use	printk format specifier.
---------------------------------------------------------
		int			%d or %x
		unsigned int		%u or %x
		long			%ld ot %lx
		unsigned long		%lu or %lx
		long long		%lld or %llx
		unsigned long long	%llu or %llx
		size_t			%zu or %zx
		ssize_t			%zd or %zx

Raw pointer value SHOULD be printed with %p.

u64 SHOULD be printed with %llu/%llx, (unsigned long long):

	printk("%llu", (unsigned long long)u64_var);

s64 SHOULD be printed with %lld/%llx, (long long):

	printk("%lld", (long long)s64_var);

If type is dependent on config option (sector_t), use format specifier
of biggest type and explicitly cast to it.

Reminder: sizeof() result is of type size_t.

Thank you for your cooperation.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-11-05 18:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-23 11:41 How do I printk <type> correctly? Alexey Dobriyan
2008-10-23 11:51 ` David John
2008-10-23 12:06   ` Alexey Dobriyan
2008-10-23 15:13 ` Johannes Berg
2008-10-23 20:40   ` David Miller
2008-10-24  8:41     ` Johannes Berg
2008-10-28 23:11 ` Randy Dunlap
2008-10-29  6:15   ` Artem Bityutskiy
2008-10-29  8:00   ` Artem Bityutskiy
2008-10-29 15:34     ` Randy Dunlap
2008-10-29 15:36       ` Artem Bityutskiy
2008-10-29 15:43         ` Randy Dunlap
2008-11-05 18:23 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).