[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <nycvar.YFH.7.77.849.2007291104100.28290@n3.vanv.qr>
Date: Wed, 29 Jul 2020 11:06:11 +0200 (CEST)
From: Jan Engelhardt <jengelh@...i.de>
To: David Laight <David.Laight@...LAB.COM>
cc: 'Christoph Hellwig' <hch@....de>,
"David S. Miller" <davem@...emloft.net>,
Ido Schimmel <idosch@...sch.org>,
"Jason A. Donenfeld" <Jason@...c4.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH 2/4] net: make sockptr_is_null strict aliasing safe
On Wednesday 2020-07-29 10:04, David Laight wrote:
>From: Christoph Hellwig <hch@....de>
>> Sent: 28 July 2020 17:39
>>
>> While the kernel in general is not strict aliasing safe we can trivially
>> do that in sockptr_is_null without affecting code generation, so always
>> check the actually assigned union member.
>
>Even with 'strict aliasing' gcc (at least) guarantees that
>the members of a union alias each other.
>It is about the only way so safely interpret a float as an int.
The only?
float given;
int i;
memcpy(&i, &given, sizeof(i));
BUILD_BUG_ON(sizeof(i) > sizeof(given));
Powered by blists - more mailing lists