From d24a2529b881ee076019d12f636dc5dad2214d9a Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Wed, 5 Jul 2023 13:51:38 +0900 Subject: [PATCH] test: Fix to initialize the buffer In src/test/test_diagnostics_data_write.c, test functions are using char array(256-byte length) as a buffer but they did not initialized. Because of this uninitialized buffers, errors were raised by the gcc-13 compiler like below: error: 'buf' may be used uninitialized To fix this issue, buffers were initialized when they are declared. Change-Id: If69983ddce58be07b3269741acd4ba9fba587936 Signed-off-by: SangYoun Kwak --- src/test/test_diagnostics_data_write.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/test_diagnostics_data_write.c b/src/test/test_diagnostics_data_write.c index 5693881..446f9fc 100644 --- a/src/test/test_diagnostics_data_write.c +++ b/src/test/test_diagnostics_data_write.c @@ -21,7 +21,7 @@ static void test_diagnostics_data_write_n1(void **state) { (void) state; - char buf[256]; + char buf[256] = { 0 }; size_t count = sizeof(buf); size_t bytes_written = 0; @@ -32,7 +32,7 @@ static void test_diagnostics_data_write_n2(void **state) { (void) state; struct _diagnostics_data_s data; - char buf[256]; + char buf[256] = { 0 }; size_t count = sizeof(buf); size_t bytes_written = 0; @@ -43,7 +43,7 @@ static void test_diagnostics_data_write_n3(void **state) { (void) state; struct _diagnostics_data_s data; - char buf[256]; + char buf[256] = { 0 }; size_t count = sizeof(buf); assert_int_equal(diagnostics_data_write(&data, buf, count, NULL), DIAGNOSTICS_ERROR_INVALID_PARAMETER); @@ -54,7 +54,7 @@ static void test_diagnostics_data_write_n4(void **state) (void) state; struct _diagnostics_data_s data; data.fd = 0; - char buf[256]; + char buf[256] = { 0 }; size_t count = sizeof(buf); size_t bytes_written = 0; @@ -69,7 +69,7 @@ static void test_diagnostics_data_write_n5(void **state) (void) state; struct _diagnostics_data_s data; data.fd = 0; - char buf[256]; + char buf[256] = { 0 }; size_t count = sizeof(buf); size_t bytes_written = 0; @@ -84,7 +84,7 @@ static void test_diagnostics_data_write_p1(void **state) (void) state; struct _diagnostics_data_s data; data.fd = 0; - char buf[256]; + char buf[256] = { 0 }; size_t count = sizeof(buf); size_t bytes_written = 0; -- 2.34.1