RE: [PATCH] xen: hypercall: fix out-of-bounds memcpy

From: David Laight
Date: Mon Feb 05 2018 - 08:58:24 EST


From: Arnd Bergmann
> Sent: 05 February 2018 12:37
....
> > Are the EVTCHNOP_xxx values dense?
> > In which case an array is almost certainly better than the switch statement.
>
> They are, yes. PHYSDEVOP_xxx are also consecutive by start at '4'.
> Dan made the same comment earlier, and I replied that my I had
> considered it but went for the more failsafe route. I also verified my
> assumption now that gcc in fact is smart enough to turn this
> into a table by itself:

I've never spotted that optimisation, must be fairly new.

David