linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: johannes@sipsolutions.net
Cc: adobriyan@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: How do I printk <type> correctly?
Date: Thu, 23 Oct 2008 13:40:05 -0700 (PDT)	[thread overview]
Message-ID: <20081023.134005.83296775.davem@davemloft.net> (raw)
In-Reply-To: <1224774806.6002.42.camel@johannes.berg>

From: Johannes Berg <johannes@sipsolutions.net>
Date: Thu, 23 Oct 2008 17:13:26 +0200

> > 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);
> 
> out of curiosity, why are there platforms that use an "unsigned long"
> for u64?

Because that type is large enough.

> An "unsigned long long" is 64-bits too even on 64-bit platforms, so
> why the difference? Are there any differences like alignment on some
> platforms?

I invite you to go make that change and then try to fixup all the
resulting build warnings.  Some of us already made an attempt at
some point in the past. :-/

But it's just papering over the core problem, that we can't extend
gcc's automatic printf format type checking easily.

Even if we make u64 the same type everywhere, things like sector_t
and other types which do have to vary by architecture will need
to be casted.

  reply	other threads:[~2008-10-23 20:40 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 [this message]
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

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=20081023.134005.83296775.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=adobriyan@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    /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).