Re: [PATCH v3 net-next 9/9] selftest: af_unix: Test SO_PASSRIGHTS.

From
Kuniyuki Iwashima <hidden>
Date
2025-05-15 20:50:35
Reply to
Willem de Bruijn, 2025-05-15
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Thu, 15 May 2025 15:27:22 -0400
quoted
@@ -227,10 +297,18 @@ void __send_fd(struct __test_metadata *_metadata,
 		.msg_control = &cmsg,
 		.msg_controllen = CMSG_SPACE(sizeof(cmsg.fd)),
 	};
-	int ret;
+	int ret, saved_errno;
 
+	errno = 0;
 	ret = sendmsg(self->fd[receiver * 2 + 1], &msg, variant->flags);
-	ASSERT_EQ(MSGLEN, ret);
+	saved_errno = errno;
+
+	if (variant->disabled) {
+		ASSERT_EQ(-1, ret);
+		ASSERT_EQ(-EPERM, -saved_errno);
+	} else {
+		ASSERT_EQ(MSGLEN, ret);
+	}
Why is this errno complexity needed?

It should never be needed to manually reset errno.

Is the saved_errno there because ASSERT_EQ on ret could call a libc
function that resets errno?
I guess it's paranoid here.

When ASSERT_EQ() calls TH_LOG(), it always fails and does
not reach the 2nd ASSERT_EQ().

Will remove them.

Thanks!
Thread (27 messages) 27 messages, 2 authors, last reply 2025-05-15
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help