From 5a00a4fe2b7f565114308513e7784b42b64794ae Mon Sep 17 00:00:00 2001 From: TapTap Date: Tue, 8 Sep 2026 22:46:43 +0200 Subject: [PATCH] =?UTF-8?q?style:=20cppcheck=20=E2=80=94=20drop=20redundan?= =?UTF-8?q?t=20if(fd>=3D0)=20in=20test=5Fxattr=20copy-fallback=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EXPECT_TRUE(fd >= 0) already guards; the enclosing if is flagged always-true by cppcheck. read(-1) is safe. --- tests/test_xattr.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/test_xattr.c b/tests/test_xattr.c index ffe95d3..44846c4 100644 --- a/tests/test_xattr.c +++ b/tests/test_xattr.c @@ -203,14 +203,12 @@ static void test_link_copy_fallback_preserves_xattrs() { /* Content landed (the copy fallback wrote the caller's bytes). */ int fd = open(dest, O_RDONLY); EXPECT_TRUE(fd >= 0); - if (fd >= 0) { - char buf[16]; - ssize_t n = read(fd, buf, sizeof(buf)); - close(fd); - EXPECT_EQ_INT((int)strlen("payload"), (int)n); - if (n == 7) - EXPECT_TRUE(memcmp(buf, "payload", 7) == 0); - } + char buf[16]; + ssize_t n = read(fd, buf, sizeof(buf)); + close(fd); + EXPECT_EQ_INT((int)strlen("payload"), (int)n); + if (n == 7) + EXPECT_TRUE(memcmp(buf, "payload", 7) == 0); /* Per-file xattr applied on the copy. */ char vbuf[16]; ssize_t vlen = getxattr(dest, "user.fallback", vbuf, sizeof(vbuf));