Re: [PATCH] firmware: cs_dsp: test_control_parse: null-terminate test strings

From: Richard Fitzgerald
Date: Wed Feb 19 2025 - 10:24:17 EST


On 11/02/2025 3:00 pm, Thomas Weißschuh wrote:
The char pointers in 'struct cs_dsp_mock_coeff_def' are expected to
point to C strings. They need to be terminated by a null byte.
However the code does not allocate that trailing null byte and only
works if by chance the allocation is followed by such a null byte.

Refactor the repeated string allocation logic into a new helper which
makes sure the terminating null is always present.
It also makes the code more readable.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
Fixes: 83baecd92e7c ("firmware: cs_dsp: Add KUnit testing of control parsing")
Cc: stable@xxxxxxxxxxxxxxx
---
.../cirrus/test/cs_dsp_test_control_parse.c | 51 ++++++++--------------
1 file changed, 19 insertions(+), 32 deletions(-)


Reviewed-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
Tested-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>