Commit a80d6771 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Mauro Carvalho Chehab

media: venus: Replace one-element arrays with flexible-array members

One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in multiple structures, and refactor the rest of the code,
accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/291
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: default avatarStanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent a0eadbe9
...@@ -233,7 +233,7 @@ static void hfi_sys_init_done(struct venus_core *core, struct venus_inst *inst, ...@@ -233,7 +233,7 @@ static void hfi_sys_init_done(struct venus_core *core, struct venus_inst *inst,
goto done; goto done;
} }
rem_bytes = pkt->hdr.size - sizeof(*pkt) + sizeof(u32); rem_bytes = pkt->hdr.size - sizeof(*pkt);
if (rem_bytes <= 0) { if (rem_bytes <= 0) {
/* missing property data */ /* missing property data */
error = HFI_ERR_SYS_INSUFFICIENT_RESOURCES; error = HFI_ERR_SYS_INSUFFICIENT_RESOURCES;
...@@ -434,7 +434,7 @@ static void hfi_session_init_done(struct venus_core *core, ...@@ -434,7 +434,7 @@ static void hfi_session_init_done(struct venus_core *core,
if (!IS_V1(core)) if (!IS_V1(core))
goto done; goto done;
rem_bytes = pkt->shdr.hdr.size - sizeof(*pkt) + sizeof(u32); rem_bytes = pkt->shdr.hdr.size - sizeof(*pkt);
if (rem_bytes <= 0) { if (rem_bytes <= 0) {
error = HFI_ERR_SESSION_INSUFFICIENT_RESOURCES; error = HFI_ERR_SESSION_INSUFFICIENT_RESOURCES;
goto done; goto done;
......
...@@ -50,7 +50,7 @@ struct hfi_msg_event_notify_pkt { ...@@ -50,7 +50,7 @@ struct hfi_msg_event_notify_pkt {
u32 event_id; u32 event_id;
u32 event_data1; u32 event_data1;
u32 event_data2; u32 event_data2;
u32 ext_event_data[1]; u32 ext_event_data[];
}; };
struct hfi_msg_event_release_buffer_ref_pkt { struct hfi_msg_event_release_buffer_ref_pkt {
...@@ -63,7 +63,7 @@ struct hfi_msg_sys_init_done_pkt { ...@@ -63,7 +63,7 @@ struct hfi_msg_sys_init_done_pkt {
struct hfi_pkt_hdr hdr; struct hfi_pkt_hdr hdr;
u32 error_type; u32 error_type;
u32 num_properties; u32 num_properties;
u32 data[1]; u32 data[];
}; };
struct hfi_msg_sys_pc_prep_done_pkt { struct hfi_msg_sys_pc_prep_done_pkt {
...@@ -81,7 +81,7 @@ struct hfi_msg_session_init_done_pkt { ...@@ -81,7 +81,7 @@ struct hfi_msg_session_init_done_pkt {
struct hfi_session_hdr_pkt shdr; struct hfi_session_hdr_pkt shdr;
u32 error_type; u32 error_type;
u32 num_properties; u32 num_properties;
u32 data[1]; u32 data[];
}; };
struct hfi_msg_session_end_done_pkt { struct hfi_msg_session_end_done_pkt {
...@@ -228,7 +228,7 @@ struct hfi_msg_session_parse_sequence_header_done_pkt { ...@@ -228,7 +228,7 @@ struct hfi_msg_session_parse_sequence_header_done_pkt {
struct hfi_session_hdr_pkt shdr; struct hfi_session_hdr_pkt shdr;
u32 error_type; u32 error_type;
u32 num_properties; u32 num_properties;
u32 data[1]; u32 data[];
}; };
struct hfi_msg_session_property_info_pkt { struct hfi_msg_session_property_info_pkt {
...@@ -247,7 +247,7 @@ struct hfi_msg_session_release_buffers_done_pkt { ...@@ -247,7 +247,7 @@ struct hfi_msg_session_release_buffers_done_pkt {
struct hfi_session_hdr_pkt shdr; struct hfi_session_hdr_pkt shdr;
u32 error_type; u32 error_type;
u32 num_buffers; u32 num_buffers;
u32 buffer_info[1]; u32 buffer_info[];
}; };
struct hfi_msg_sys_debug_pkt { struct hfi_msg_sys_debug_pkt {
...@@ -256,7 +256,7 @@ struct hfi_msg_sys_debug_pkt { ...@@ -256,7 +256,7 @@ struct hfi_msg_sys_debug_pkt {
u32 msg_size; u32 msg_size;
u32 time_stamp_hi; u32 time_stamp_hi;
u32 time_stamp_lo; u32 time_stamp_lo;
u8 msg_data[1]; u8 msg_data[];
}; };
struct hfi_msg_sys_coverage_pkt { struct hfi_msg_sys_coverage_pkt {
...@@ -264,7 +264,7 @@ struct hfi_msg_sys_coverage_pkt { ...@@ -264,7 +264,7 @@ struct hfi_msg_sys_coverage_pkt {
u32 msg_size; u32 msg_size;
u32 time_stamp_hi; u32 time_stamp_hi;
u32 time_stamp_lo; u32 time_stamp_lo;
u8 msg_data[1]; u8 msg_data[];
}; };
struct venus_core; struct venus_core;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment