diff mbox series

selftests/alsa:Replace malloc with calloc

Message ID 20240626095409.4908-1-zhujun2@cmss.chinamobile.com (mailing list archive)
State New
Headers show
Series selftests/alsa:Replace malloc with calloc | expand

Commit Message

Zhu Jun June 26, 2024, 9:54 a.m. UTC
Using calloc to handling memory allocation, calloc
can initialize the allocated memory

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/testing/selftests/alsa/test-pcmtest-driver.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Mark Brown June 26, 2024, 10:41 a.m. UTC | #1
On Wed, Jun 26, 2024 at 02:54:09AM -0700, Zhu Jun wrote:
> Using calloc to handling memory allocation, calloc
> can initialize the allocated memory

>  		SKIP(return, "Can't read patterns. Probably, module isn't loaded");
>  
>  	card_name = malloc(127);
> +	memset(card_name, 0, 127);
>  	ASSERT_NE(card_name, NULL);
>  	self->params.buffer_size = 16384;
>  	self->params.period_size = 4096;

The change does not match the changelog.
diff mbox series

Patch

diff --git a/tools/testing/selftests/alsa/test-pcmtest-driver.c b/tools/testing/selftests/alsa/test-pcmtest-driver.c
index ca81afa4ee90..0a551b5f41f7 100644
--- a/tools/testing/selftests/alsa/test-pcmtest-driver.c
+++ b/tools/testing/selftests/alsa/test-pcmtest-driver.c
@@ -134,6 +134,7 @@  FIXTURE_SETUP(pcmtest) {
 		SKIP(return, "Can't read patterns. Probably, module isn't loaded");
 
 	card_name = malloc(127);
+	memset(card_name, 0, 127);
 	ASSERT_NE(card_name, NULL);
 	self->params.buffer_size = 16384;
 	self->params.period_size = 4096;