PERFORCE change 131207 for review
John Birrell
jb at FreeBSD.org
Tue Dec 18 19:24:30 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=131207
Change 131207 by jb at jb_freebsd1 on 2007/12/19 03:24:25
Rather than just accepting compiler warnings given that the code has
been linted, let's just code it cleanly.
This is necessary for FreeBSD/arm. gcc 4.2 gets stroppy if it thinks
we're dereferencing pointers that aren't 32-bit aligned.
Affected files ...
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/dump/dump.c#9 edit
Differences ...
==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/dump/dump.c#9 (text) ====
@@ -203,9 +203,8 @@
static int
print_labeltable(const ctf_header_t *hp, const ctf_data_t *cd)
{
- /* LINTED - pointer alignment */
- const ctf_lblent_t *ctl = (ctf_lblent_t *)(cd->cd_ctfdata +
- hp->cth_lbloff);
+ void *v = (void *) (cd->cd_ctfdata + hp->cth_lbloff);
+ const ctf_lblent_t *ctl = v;
ulong_t i, n = (hp->cth_objtoff - hp->cth_lbloff) / sizeof (*ctl);
print_line("- Label Table ");
@@ -267,8 +266,8 @@
static int
read_data(const ctf_header_t *hp, const ctf_data_t *cd)
{
- /* LINTED - pointer alignment */
- const ushort_t *idp = (ushort_t *)(cd->cd_ctfdata + hp->cth_objtoff);
+ void *v = (void *) (cd->cd_ctfdata + hp->cth_objtoff);
+ const ushort_t *idp = v;
ulong_t n = (hp->cth_funcoff - hp->cth_objtoff) / sizeof (ushort_t);
if (flags != F_STATS)
@@ -311,11 +310,11 @@
static int
read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
{
- /* LINTED - pointer alignment */
- const ushort_t *fp = (ushort_t *)(cd->cd_ctfdata + hp->cth_funcoff);
+ void *v = (void *) (cd->cd_ctfdata + hp->cth_funcoff);
+ const ushort_t *fp = v;
- /* LINTED - pointer alignment */
- const ushort_t *end = (ushort_t *)(cd->cd_ctfdata + hp->cth_typeoff);
+ v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
+ const ushort_t *end = v;
ulong_t id;
int symidx;
@@ -388,11 +387,11 @@
static int
read_types(const ctf_header_t *hp, const ctf_data_t *cd)
{
- /* LINTED - pointer alignment */
- const ctf_type_t *tp = (ctf_type_t *)(cd->cd_ctfdata + hp->cth_typeoff);
+ void *v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
+ const ctf_type_t *tp = v;
- /* LINTED - pointer alignment */
- const ctf_type_t *end = (ctf_type_t *)(cd->cd_ctfdata + hp->cth_stroff);
+ v = (void *) (cd->cd_ctfdata + hp->cth_stroff);
+ const ctf_type_t *end = v;
ulong_t id;
@@ -930,15 +929,15 @@
if (cd.cd_ctflen < sizeof (ctf_preamble_t))
die("%s does not contain a CTF preamble\n", filename);
- /* LINTED - pointer alignment */
- pp = (const ctf_preamble_t *)cd.cd_ctfdata;
+ void *v = (void *) cd.cd_ctfdata;
+ pp = v;
if (pp->ctp_magic != CTF_MAGIC)
die("%s does not appear to contain CTF data\n", filename);
if (pp->ctp_version == CTF_VERSION) {
- /* LINTED - pointer alignment */
- hp = (ctf_header_t *)cd.cd_ctfdata;
+ v = (void *) cd.cd_ctfdata;
+ hp = v;
cd.cd_ctfdata = (caddr_t)cd.cd_ctfdata + sizeof (ctf_header_t);
if (cd.cd_ctflen < sizeof (ctf_header_t)) {
More information about the p4-projects
mailing list