[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250828083058.2173695-1-zhouyuhang1010@163.com>
Date: Thu, 28 Aug 2025 16:30:58 +0800
From: zhouyuhang <zhouyuhang1010@....com>
To: shuah@...nel.org
Cc: linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zhou Yuhang <zhouyuhang@...inos.cn>
Subject: [PATCH] selftests: filelock: Initialize the flock to zero
From: Zhou Yuhang <zhouyuhang@...inos.cn>
Flock fl and fl2 are not initialized after definition.
Due to struct padding, this may cause memcmp() to return
a non-zero value. The output is as follows:
# [INFO] opened fds 3 4
# [SUCCESS] set OFD read lock on first fd
# [SUCCESS] read and write locks conflicted
# [SUCCESS] F_UNLCK test returns: locked, type 0 pid -1 len 3
# [FAIL] F_UNLCK test returns: locked, type 0 pid -1 len 3
Initialize them to zero to solve this problem.
Signed-off-by: Zhou Yuhang <zhouyuhang@...inos.cn>
---
tools/testing/selftests/filelock/ofdlocks.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/filelock/ofdlocks.c b/tools/testing/selftests/filelock/ofdlocks.c
index a55b79810ab2..84e25505bebb 100644
--- a/tools/testing/selftests/filelock/ofdlocks.c
+++ b/tools/testing/selftests/filelock/ofdlocks.c
@@ -36,6 +36,8 @@ int main(void)
{
int rc;
struct flock fl, fl2;
+ memset(&fl, 0, sizeof(fl));
+ memset(&fl2, 0, sizeof(fl2));
int fd = open("/tmp/aa", O_RDWR | O_CREAT | O_EXCL, 0600);
int fd2 = open("/tmp/aa", O_RDONLY);
--
2.33.0
Powered by blists - more mailing lists