linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: dedekind@infradead.org
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	ericvh@gmail.com, mfasheh@suse.com
Subject: Re: How do I printk <type> correctly?
Date: Wed, 29 Oct 2008 08:34:03 -0700	[thread overview]
Message-ID: <20081029083403.5afac2c1.randy.dunlap@oracle.com> (raw)
In-Reply-To: <1225267204.4350.10.camel@sauron>

On Wed, 29 Oct 2008 10:00:04 +0200 Artem Bityutskiy wrote:

> On Tue, 2008-10-28 at 16:11 -0700, Randy Dunlap wrote:
> > On Thu, 23 Oct 2008 15:41:33 +0400 Alexey Dobriyan wrote:
> > 
> > > 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.
> 
> Do we have this somewhere in Documentation? Would be nice to have it.

It's in the C standard, which we don't try to put into Documentation/ AFAIK.

section 6.5.3.4, The sizeof operator:

4 The value of the result is implementation-defined, and its type (an unsigned integer type)
is size_t, defined in <stddef.h> (and other headers).


---
~Randy

  reply	other threads:[~2008-10-29 15:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2008-10-29 15:36       ` Artem Bityutskiy
2008-10-29 15:43         ` Randy Dunlap
2008-11-05 18:23 ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081029083403.5afac2c1.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=adobriyan@gmail.com \
    --cc=dedekind@infradead.org \
    --cc=ericvh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfasheh@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).