On Thu, Aug 17, 2017 at 5:15 AM, David Laight <david.lai...@aculab.com> wrote: > From: Willem de Bruijn >> Sent: 17 August 2017 00:27 >> Actually, it is safe even without the check. Overflow of the signed integer >> is benign here. > > IIRC the C language states that 'signed integer overflow' is undefined. > So 'MAXINT + 1' doesn't have to equal '-MAXINT - 1' (as one would > expect on a 2's compliment system). > > While the linux kernel probably won't run on systems where this isn't true > (eg where signed arithmetic saturates) gcc will assume it can't happen > and optimise code with that assumption.
Ah, of course. Thanks. The last patch does not rely on such tricks, indeed. On rereading, it is actually very similar to Matthew's original. The main difference is handling the negative offset case inside __skb_try_recv_from_queue instead of in each caller.