Thread (5 messages) 5 messages, 2 authors, 22d ago

Re: [PATCH v2] mctp: serial: replace memset with zero-initialization

From: David Laight <hidden>
Date: 2026-05-31 09:12:41
Also in: lkml

On Sat, 30 May 2026 22:46:46 +0000
Manish Baing [off-list ref] wrote:
Use empty brace initialization (= {}) instead of explicit memset()
to zero-initialize stack memory to simplify the code.

No functional change.
Isn't it also entirely pointless?

-- David
quoted hunk ↗ jump to hunk
Signed-off-by: Manish Baing <redacted>
---
Changes in v2:
- Fixed a compilation error caused by a duplicate variable declaration caught 
  by the kernel test robot.

 drivers/net/mctp/mctp-serial.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c
index 26c9a33fd636..df721ca4e07b 100644
--- a/drivers/net/mctp/mctp-serial.c
+++ b/drivers/net/mctp/mctp-serial.c
@@ -536,13 +536,12 @@ struct test_chunk_tx {
 
 static void test_next_chunk_len(struct kunit *test)
 {
-	struct mctp_serial devx;
+	struct mctp_serial devx = { };
 	struct mctp_serial *dev = &devx;
 	int next;
 
 	const struct test_chunk_tx *params = test->param_value;
 
-	memset(dev, 0x0, sizeof(*dev));
 	memcpy(dev->txbuf, params->input, params->input_len);
 	dev->txlen = params->input_len;
 
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help