Messages in this thread | | | Date | Thu, 25 Mar 2021 09:12:27 +0100 | From | Robert Richter <> | Subject | Re: [PATCH] cxl/mem: Force array size of mem_commands[] to CXL_MEM_COMMAND_ID_MAX |
| |
On 24.03.21 12:08:20, Dan Williams wrote: > On Wed, Mar 24, 2021 at 11:43 AM Ira Weiny <ira.weiny@intel.com> wrote:
> > Can't we use ARRAY_SIZE? > > An ARRAY_SIZE() check in cxl_validate_cmd_from_user() would work too, > but it wouldn't give the compiler protection that Robert mentions for > going the other way where mem_commands tries to add an entry that is > out of bounds relative to CXL_CMDS.
I was considering that too. Another reason apart from above was to treat 'holes' in the array caused by #ifdefs the same regardless its position in the array. Thus, all should show up as being zeroed instead of cutting those at the end from the array.
Thanks for applying,
-Robert
| |