Re: [PATCH][next] scsi: aacraid: Replace one-element array with flexible-array member

From: Martin K. Petersen
Date: Tue Apr 13 2021 - 00:52:31 EST



Hi Kees/Gustavo!

>> @@ -4020,7 +4020,8 @@ static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int
>> }
>> }
>> sge[pos] = rio2->sge[nseg-1];
>> - memcpy(&rio2->sge[1], &sge[1], (nseg_new-1)*sizeof(struct sge_ieee1212));
>> + memcpy(&rio2->sge[1], &sge[1],
>> + flex_array_size(rio2, sge, nseg_new - 1));
>
> This was hard to validate,

... which is why I didn't apply this patch. I don't like changes which
make the reader have to jump through hoops to figure out what the code
actually does. I find the original much easier to understand.

Silencing analyzer warnings shouldn't be done at the expense of human
readers. If it is imperative to switch to flex_array_size() to quiesce
checker warnings, please add a comment in the code explaining that the
size evaluates to nseg_new-1 sge_ieee1212 structs.

--
Martin K. Petersen Oracle Linux Engineering