[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D0F6DAA4B@AcuExch.aculab.com>
Date: Tue, 11 Mar 2014 15:51:59 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Vince Bridgers' <vbridgers2013@...il.com>,
Stephen Hemminger <stephen@...workplumber.org>
CC: "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"robh+dt@...nel.org" <robh+dt@...nel.org>,
"pawel.moll@....com" <pawel.moll@....com>,
"mark.rutland@....com" <mark.rutland@....com>,
"ijc+devicetree@...lion.org.uk" <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>,
Rob Landley <rob@...dley.net>
Subject: RE: [PATCH net-next v2 8/9] Altera TSE: Add Miscellaneous Files for
Altera Ethernet Driver
From: Vince Bridgers
> On Mon, Mar 10, 2014 at 7:40 PM, Stephen Hemminger
> <stephen@...workplumber.org> wrote:
> > On Mon, 10 Mar 2014 18:14:36 -0500
> > Vince Bridgers <vbridgers2013@...il.com> wrote:
> >
> >> +
> >> + buf[0] = (u64) ioread32(&mac->frames_transmitted_ok);
> >
> > The cast to u64 is not really necessary, C will do it for you.
> > You do need the cast to do the shift for the 64 bit values.
>
> Ok, understood. I generally add the cast so it's explicit, but I'll modify.
The problem is that the cast will allow incorrect code to compile.
eg, you might have a pointer, not an integer.
Many years ago I got caught out by a #define like the following:
#define foo(ptr) { int s = splhi(); do_foo((void *)ptr); splx(s); }
My code crashed because I'd called foo(s).
Now that #define is broken in so many ways, but the (void *) cast
stopped the compiler erroring one of them.
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists