[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B6F71@saturn3.aculab.com>
Date: Mon, 2 Jul 2012 13:15:12 +0100
From: "David Laight" <David.Laight@...LAB.COM>
To: "Andreas Schwab" <schwab@...ux-m68k.org>
Cc: "Joe Perches" <joe@...ches.com>,
"Ben Hutchings" <bhutchings@...arflare.com>,
"Or Gerlitz" <ogerlitz@...lanox.com>, <davem@...emloft.net>,
<roland@...nel.org>, <yevgenyp@...lanox.com>, <oren@...lanox.com>,
<netdev@...r.kernel.org>, "Hadar Hen Zion" <hadarh@...lanox.co.il>
Subject: RE: [PATCH net-next 09/10] net/mlx4_en: Manage flow steering rules with ethtool
> "David Laight" <David.Laight@...LAB.COM> writes:
>
> >
> >> > Or write it as (!field || !(typeof(field))~field) which more
closely
> >> > resembles what the macro name expresses.
> >>
> >> Better still, or maybe:
> >>
> >> field == 0 || field == (typeof field)~0
> >
> > Which doesn't work when sizeof(field) > sizeof(int).
> > Needs another cast.
> >
> > field == 0 || field == (typeof field)~(typeof field)0
>
> You can avoid that by using (typeof field)-1.
Gah, I thought I knew the integral promotion rules!
-1 and ~0 are both 'integer' and get treated the same.
A quick test shows that gcc does sign extend when converting
32bit int to 64bit unsigned long long.
Which probably means that is required by the standard!
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