[PATCH v2 10/18] media: venus: Use flex array for hfi_session_release_buffer_pkt

Ricardo Ribalda posted 18 patches 1 year, 9 months ago
There is a newer version of this series
[PATCH v2 10/18] media: venus: Use flex array for hfi_session_release_buffer_pkt
Posted by Ricardo Ribalda 1 year, 9 months ago
Replace the old style single element array with a flex array. We do not
allocate this structure, so the size change should not be an issue.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_cmds.h:204:5-16: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.h b/drivers/media/platform/qcom/venus/hfi_cmds.h
index 41f765eac4d9..6dff949c4402 100644
--- a/drivers/media/platform/qcom/venus/hfi_cmds.h
+++ b/drivers/media/platform/qcom/venus/hfi_cmds.h
@@ -201,7 +201,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[1];
+	u32 buffer_info[];
 };
 
 struct hfi_session_release_resources_pkt {

-- 
2.45.0.rc1.225.g2a3ae87e7f-goog
Re: [PATCH v2 10/18] media: venus: Use flex array for hfi_session_release_buffer_pkt
Posted by Bryan O'Donoghue 1 year, 9 months ago
On 07/05/2024 17:27, Ricardo Ribalda wrote:
> Replace the old style single element array with a flex array. We do not
> allocate this structure, so the size change should not be an issue.
> 
> This fixes the following cocci warning:
> drivers/media/platform/qcom/venus/hfi_cmds.h:204:5-16: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>   drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.h b/drivers/media/platform/qcom/venus/hfi_cmds.h
> index 41f765eac4d9..6dff949c4402 100644
> --- a/drivers/media/platform/qcom/venus/hfi_cmds.h
> +++ b/drivers/media/platform/qcom/venus/hfi_cmds.h
> @@ -201,7 +201,7 @@ struct hfi_session_release_buffer_pkt {
>   	u32 extradata_size;
>   	u32 response_req;
>   	u32 num_buffers;
> -	u32 buffer_info[1];
> +	u32 buffer_info[];
>   };
>   
>   struct hfi_session_release_resources_pkt {
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Re: [PATCH v2 10/18] media: venus: Use flex array for hfi_session_release_buffer_pkt
Posted by Bryan O'Donoghue 1 year, 9 months ago
On 10/05/2024 00:37, Bryan O'Donoghue wrote:
>> -    u32 buffer_info[1];
>> +    u32 buffer_info[];
>>   };
>>   struct hfi_session_release_resources_pkt {
>>
> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

Oops no.

Please don't change the size of the structure.

u32 buffer_info;

---
bod
Re: [PATCH v2 10/18] media: venus: Use flex array for hfi_session_release_buffer_pkt
Posted by Ricardo Ribalda 1 year, 8 months ago
Hi Bryan


On Fri, 10 May 2024 at 02:10, Bryan O'Donoghue
<bryan.odonoghue@linaro.org> wrote:
>
> On 10/05/2024 00:37, Bryan O'Donoghue wrote:
> >> -    u32 buffer_info[1];
> >> +    u32 buffer_info[];
> >>   };
> >>   struct hfi_session_release_resources_pkt {
> >>
> > Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>
> Oops no.
>
> Please don't change the size of the structure.

In this case buffer_info[] is a real flexible array, so there is not
much we can do.

The driver seems to only uses the structure to address memory. It is
not allocating the structure or doing any calculations based on its
size, so it should be fine (famous last words).

If anyone has access to the hardware it would be great if they tested it :)

>
> u32 buffer_info;
>
> ---
> bod



-- 
Ricardo Ribalda