media: venus: hfi_cmds.h: Replace one-element array with flexible-array member
Subsystems (4)
PATCH 1/1 media: venus: hfi_cmds.h: Replace one-element array with flexible-array member
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
Use flexible-array member in struct hfi_sys_set_property_pkt instead of one-element array.
Also, this helps with the ongoing efforts to enable -Warray-bounds and fix the following warnings:
drivers/media/platform/qcom/venus/hfi_cmds.c: In function ‘pkt_sys_coverage_config’:drivers/media/platform/qcom/venus/hfi_cmds.c:57:11: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
57 | pkt->data[1] = mode;
| ~~~~~~~~~^~~[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays
--- drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -68,7 +68,7 @@ struct hfi_sys_release_resource_pkt {struct hfi_sys_set_property_pkt {struct hfi_pkt_hdr hdr;u32 num_properties; -u32 data[1 ]; +u32 data[]; };struct hfi_sys_get_property_pkt {
Signature · 1 line
2.27.0
Hi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 44 lines · Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
Use flexible-array member in struct
hfi_sys_set_property_pktinstead of one-element array.Also, this helps with the ongoing efforts to enable -Warray-bounds and fix the following warnings:
drivers/media/platform/qcom/venus/hfi_cmds.c: In function ‘pkt_sys_coverage_config’:drivers/media/platform/qcom/venus/hfi_cmds.c:57:11: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]57 | pkt->data[1] = mode; | ~~~~~~~~~^~~[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arraysBuild-tested-by kernel test robot <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/venus/hfi_cmds.h +1
-1@@ -68,7 +68,7 @@ struct hfi_sys_release_resource_pkt {struct hfi_sys_set_property_pkt {struct hfi_pkt_hdr hdr;u32 num_properties; -u32 data[1 ]; +u32 data[]; };struct hfi_sys_get_property_pkt {Signature · 1 line
2.27.0
Hi all,
Friendly ping:
We are about to be able to globally enable -Warray-bounds and, this is one of the last out-of-bounds warnings in linux-next.
Could someone take this, please?
Thanks
--
Gustavo
Quoted 42 lines · Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
Use flexible-array member in struct
hfi_sys_set_property_pktinstead of one-element array.Also, this helps with the ongoing efforts to enable -Warray-bounds and fix the following warnings:
drivers/media/platform/qcom/venus/hfi_cmds.c: In function ‘pkt_sys_coverage_config’:drivers/media/platform/qcom/venus/hfi_cmds.c:57:11: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]57 | pkt->data[1] = mode; | ~~~~~~~~~^~~[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arraysBuild-tested-by kernel test robot <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/venus/hfi_cmds.h +1
-1@@ -68,7 +68,7 @@ struct hfi_sys_release_resource_pkt {struct hfi_sys_set_property_pkt {struct hfi_pkt_hdr hdr;u32 num_properties; -u32 data[1 ]; +u32 data[]; };struct hfi_sys_get_property_pkt {
Hi,
Quoted 8 lines · Gustavo A. R. Silva
Hi all,
Friendly ping:
We are about to be able to globally enable -Warray-bounds and, this is one of the last out-of-bounds warnings in linux-next.
Could someone take this, please?
I'll take this for 5.14.
Quoted 48 lines
Thanks
--
GustavoQuoted 42 lines · Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
Use flexible-array member in struct
hfi_sys_set_property_pktinstead of one-element array.Also, this helps with the ongoing efforts to enable -Warray-bounds and fix the following warnings:
drivers/media/platform/qcom/venus/hfi_cmds.c: In function ‘pkt_sys_coverage_config’:drivers/media/platform/qcom/venus/hfi_cmds.c:57:11: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]57 | pkt->data[1] = mode; | ~~~~~~~~~^~~[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arraysBuild-tested-by kernel test robot <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/venus/hfi_cmds.h +1
-1@@ -68,7 +68,7 @@ struct hfi_sys_release_resource_pkt {struct hfi_sys_set_property_pkt {struct hfi_pkt_hdr hdr;u32 num_properties; -u32 data[1 ]; +u32 data[]; };struct hfi_sys_get_property_pkt {
Signature · 2 lines
regards, Stan