diff mbox series

[liburing,v1,02/10] test/eeed8b54e0df: Initialize the `malloc()`ed buffer before `write()`

Message ID 20220810002735.2260172-3-ammar.faizi@intel.com (mailing list archive)
State New
Headers show
Series liburing test fixes | expand

Commit Message

Ammar Faizi Aug. 10, 2022, 12:31 a.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

... to avoid valgrind's complaint:

  ==3054187== Syscall param write(buf) points to uninitialised byte(s)
  ==3054187==    at 0x4958E63: write (write.c:26)
  ==3054187==    by 0x109283: get_file_fd (eeed8b54e0df.c:36)
  ==3054187==    by 0x109283: main (eeed8b54e0df.c:85)
  ==3054187==  Address 0x4a63080 is 0 bytes inside a block of size 4,096 alloc'd
  ==3054187==    at 0x484479B: malloc (vg_replace_malloc.c:380)
  ==3054187==    by 0x109698: t_malloc (helpers.c:22)
  ==3054187==    by 0x109270: get_file_fd (eeed8b54e0df.c:35)
  ==3054187==    by 0x109270: main (eeed8b54e0df.c:85)

Link: https://github.com/axboe/liburing/issues/640
Reported-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 test/eeed8b54e0df.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/test/eeed8b54e0df.c b/test/eeed8b54e0df.c
index b388b12..b8149f2 100644
--- a/test/eeed8b54e0df.c
+++ b/test/eeed8b54e0df.c
@@ -33,6 +33,7 @@  static int get_file_fd(void)
 	}
 
 	buf = t_malloc(BLOCK);
+	memset(buf, 0, BLOCK);
 	ret = write(fd, buf, BLOCK);
 	if (ret != BLOCK) {
 		if (ret < 0)