RE: [PATCH v4 10/24] crypto: x86/poly - limit FPU preemption
From: David Laight
Date: Tue Nov 22 2022 - 04:08:21 EST
From: Elliott, Robert
> Sent: 22 November 2022 05:06
...
> Since enum doesn't guarantee any particular type, those variations
> upset the min() macro. min_t() is necessary to eliminate the
> compiler warning.
Yes, min() is fundamentally broken. min_t() isn't really a solution.
I think min() needs to include something like:
#define min(a, b) \
__builtin_constant(b) && (b) + 0u <= MAX_INT ? \
((a) < (int)(b) ? (a) : (int)(b)) : \
...
So in the common case where 'b' is a small constant integer it
doesn't matter whether the is it signed or unsigned.
I might try compiling a kernel where min_t() does that instead
of the casts - just to see how many of the casts are actually
needed.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)