Commit 4fe6a630 authored by Stephen Kitt's avatar Stephen Kitt Committed by Mark Brown

ASoC: SOF: Replace zero-length 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].

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/78
Link: https://github.com/KSPP/linux/issues/180Suggested-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: default avatarStephen Kitt <steve@sk2.org>
Acked-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20220217132755.1786130-1-steve@sk2.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 83bfc7e7
...@@ -237,7 +237,7 @@ struct sof_ipc_comp_process { ...@@ -237,7 +237,7 @@ struct sof_ipc_comp_process {
/* reserved for future use */ /* reserved for future use */
uint32_t reserved[7]; uint32_t reserved[7];
uint8_t data[0]; uint8_t data[];
} __packed; } __packed;
/* frees components, buffers and pipelines /* frees components, buffers and pipelines
......
...@@ -2164,7 +2164,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, ...@@ -2164,7 +2164,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index,
*/ */
if (ipc_data_size) { if (ipc_data_size) {
for (i = 0; i < widget->num_kcontrols; i++) { for (i = 0; i < widget->num_kcontrols; i++) {
memcpy(&process->data + offset, memcpy(&process->data[offset],
wdata[i].pdata->data, wdata[i].pdata->data,
wdata[i].pdata->size); wdata[i].pdata->size);
offset += wdata[i].pdata->size; offset += wdata[i].pdata->size;
......
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