firmware: cs_dsp: test_control_parse: null-terminate test strings
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Tue, 11 Feb 2025 15:00:02 +0000 (16:00 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 19 Feb 2025 23:08:31 +0000 (23:08 +0000)
commit42ae6e2559e63c2d4096b698cd47aaeb974436df
treee54c5ed06e4ac7689d15afe5a2d3e24d9656466c
parent2e2f89b184644f0e29f1ec0b4dcfd0361d2635cb
firmware: cs_dsp: test_control_parse: null-terminate test strings

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@linutronix.de>
Fixes: 83baecd92e7c ("firmware: cs_dsp: Add KUnit testing of control parsing")
Cc: stable@vger.kernel.org
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Tested-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20250211-cs_dsp-kunit-strings-v1-1-d9bc2035d154@linutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c