From: der.herr@hofr.at (Nicholas Mc Guire)
To: kernelnewbies@lists.kernelnewbies.org
Subject: single, comprehensive kernel data types document?
Date: Fri, 15 Apr 2016 15:59:09 +0000 [thread overview]
Message-ID: <20160415155909.GA13082@osadl.at> (raw)
In-Reply-To: <20160415122724.GA7389@kroah.com>
On Fri, Apr 15, 2016 at 05:27:24AM -0700, Greg KH wrote:
> On Fri, Apr 15, 2016 at 08:04:53AM -0400, Robert P. J. Day wrote:
> >
> > is there a single, decent online doc that explains the proper data
> > types (int16_t, int32_t and so on) to use in kernel code?
>
> First off, never use int16_t and friends, that's not ok :)
>
> Second, it's simple, use:
> u8
> u16
> u32
> u64
> and friends in kernel code (s8, s16, and so on for signed values.)
>
I don?t think its quite that simple - as an exampe here is a part of the
variations of chars that exist in the kernel:
Type : equivalent types (basis 4.0 x86 64)
char : signed char, __signed__ char, __s8, s8, int8_t
unsigned char : unsigned char, u_char, __u8, u8, unchar, u_int8_t, uint8_t
__ticket_t,
insn_byte_t,
kprobe_opcode_t
Now for new unsigned char objects it might be good enough to simply use
u8 but it does depend on the subsystem and if that has some typedef in
use or not or readability could really suffer.
It would however make a lot of sense I belive if a list of types that
should be used and which should no longer be used were available.
Probably a number of the above typedef might actually be deprecated for
any new code (and char is actually one of the shorter lists - unsigned
short, unsigned int, unsigned long have atleast 25 equivalent typedefs
each).
So a typedef cleanup would make a lot of sense for new conributors and it
would also help readability as well as make static code analysis easier...
If the above recommendation {u,s}{8,16,32,64} is somehow official policy
for new code, then it maybe should go into Documentation/CodingStyle ?
thx!
hofrat
next prev parent reply other threads:[~2016-04-15 15:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 12:04 single, comprehensive kernel data types document? Robert P. J. Day
2016-04-15 12:27 ` Greg KH
2016-04-15 12:37 ` John Chludzinski
2016-04-15 13:08 ` Silvan Jegen
2016-04-15 13:09 ` Daniel.
2016-04-15 13:55 ` Greg KH
2016-04-15 16:28 ` Daniel.
2016-04-15 13:53 ` Greg KH
2016-04-15 15:59 ` Nicholas Mc Guire [this message]
2016-04-15 16:18 ` Greg KH
2016-04-15 17:07 ` Valdis.Kletnieks at vt.edu
2016-04-15 20:15 ` Greg KH
2016-04-20 20:37 ` Rob Groner
2016-04-21 2:51 ` Greg KH
2016-04-21 12:51 ` Rob Groner
2016-04-21 19:34 ` Josh Cartwright
2016-04-22 2:37 ` Greg KH
2016-04-22 3:02 ` Valdis.Kletnieks at vt.edu
2016-04-22 3:13 ` Greg KH
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=20160415155909.GA13082@osadl.at \
--to=der.herr@hofr.at \
--cc=kernelnewbies@lists.kernelnewbies.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).