From 1c2dc9c8d10aff2d63734fb5cb01eefcc19f6e1b Mon Sep 17 00:00:00 2001 From: Oscar Waddell Date: Tue, 23 Apr 2019 11:26:47 +0200 Subject: [PATCH] linux: init st_flags and st_gen when using statx Explicitly initialize uv_stat_t fields st_flags and st_gen when using statx as uv__to_stat does when statx is not available. This makes valgrind happier. PR-URL: https://github.com/libuv/libuv/pull/2263 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Jameson Nash --- src/unix/fs.c | 2 ++ test/test-fs.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/unix/fs.c b/src/unix/fs.c index c6d2259a..b03ff778 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -1165,6 +1165,8 @@ static int uv__fs_statx(int fd, buf->st_ctim.tv_nsec = statxbuf.stx_ctime.tv_nsec; buf->st_birthtim.tv_sec = statxbuf.stx_btime.tv_sec; buf->st_birthtim.tv_nsec = statxbuf.stx_btime.tv_nsec; + buf->st_flags = 0; + buf->st_gen = 0; return 0; #else diff --git a/test/test-fs.c b/test/test-fs.c index 35f7d0c3..77516f85 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -1171,6 +1171,7 @@ TEST_IMPL(fs_fstat) { ASSERT(req.result == sizeof(test_buf)); uv_fs_req_cleanup(&req); + memset(&req.statbuf, 0xaa, sizeof(req.statbuf)); r = uv_fs_fstat(NULL, &req, file, NULL); ASSERT(r == 0); ASSERT(req.result == 0); @@ -1257,6 +1258,8 @@ TEST_IMPL(fs_fstat) { s->st_birthtim.tv_sec == t.st_ctim.tv_sec); ASSERT(s->st_birthtim.tv_nsec == 0 || s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec); + ASSERT(s->st_flags == 0); + ASSERT(s->st_gen == 0); #endif uv_fs_req_cleanup(&req);