From: "David Laight" <David.Laight@ACULAB.COM>
To: "Tabi Timur-B04825" <B04825@freescale.com>
Cc: linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Xie Shaohui-B21989 <B21989@freescale.com>
Subject: RE: [PATCH] powerpc/usb: use unsigned long to type cast an address of ioremap
Date: Thu, 3 Nov 2011 12:16:02 -0000 [thread overview]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6D8AEA4@saturn3.aculab.com> (raw)
In-Reply-To: <4EB283F5.6000202@freescale.com>
> >> > usb_sys_regs =3D (void *)dr_regs + USB_DR_SYS_OFFSET;
>=20
> > But that is invalid C.
>=20
> What's invalid about it? I haven't tried compiling this=20
> specific line of code, but I've done stuff like it in the past many
times.
>=20
> Are you talking about adding an integer to a void pointer? =20
> If so, then that's something that gcc supports and that the kernel
uses=20
> all over the place.
Arithmetic on 'void *' should not be done. I know some versions of
gcc allow it (provided some warning level/option is enabled) but
that doesn't mean it is valid.
My suspicions are that is was allowed due to the way 'void *'
was originally bodged into gcc.
> A char* is incorrect because a char could be more=20
> than one byte, in theory.
It is somewhat difficult to untangle the standard, but
sizeof (char) is defined to be one.
Of course, the C language doesn't actually require that
you can converts between pointers to different types in
any well-defined manner. But most of the low level device
access assumes an adequately linear address space.
David
next prev parent reply other threads:[~2011-11-03 12:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-03 9:58 [PATCH] powerpc/usb: use unsigned long to type cast an address of ioremap Shaohui Xie
2011-11-03 11:14 ` David Laight
2011-11-03 11:38 ` Tabi Timur-B04825
2011-11-03 11:38 ` David Laight
2011-11-03 12:07 ` Tabi Timur-B04825
2011-11-03 12:16 ` David Laight [this message]
2011-11-03 14:12 ` Timur Tabi
2011-11-03 22:08 ` Segher Boessenkool
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=AE90C24D6B3A694183C094C60CF0A2F6D8AEA4@saturn3.aculab.com \
--to=david.laight@aculab.com \
--cc=B04825@freescale.com \
--cc=B21989@freescale.com \
--cc=linux-usb@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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).