[PATCH] Fix the man page of setsockopt.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,
  We are annotating setsockopt()
[https://man7.org/linux/man-pages/man2/setsockopt.2.html] and we will
make optval _Nonnull because of the implementation:
https://elixir.bootlin.com/linux/latest/source/include/linux/sockptr.h#L44
but we find something confusing in the linux man page.

   From the linux man page, it said The option value is ignored. This
is strictly correct but this one should be corrected: If no option
value is to be supplied or returned, optval may be NULL. It should be
corrected and make it clear that it is _Nonnull.

  Also, to prove optval  should be _Nonnull, enh wrote a trivial test
program to open a socket and call SO_DETACH_FILTER. He got EINVAL for
null, but ENOENT for a dummy value, which makes sense, because he
doesn’t actually have a filter to detach, so that's the expected
error.

   Thank you!

Best,
Zijun Zhao
From 2a68453937c462cf8871a02d62002a0d8461d0b0 Mon Sep 17 00:00:00 2001
From: Zijun Zhao <zijunzhao@google.com>
Date: Wed, 31 May 2023 11:16:11 -0700
Subject: [PATCH] Modify getsockopt.2 documentation

---
 man2/getsockopt.2 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/man2/getsockopt.2 b/man2/getsockopt.2
index a0cda8e87..28059793a 100644
--- a/man2/getsockopt.2
+++ b/man2/getsockopt.2
@@ -77,9 +77,10 @@ size of the buffer pointed to by
 .IR optval ,
 and modified on return to indicate the actual size of
 the value returned.
-If no option value is to be supplied or returned,
 .I optval
-may be NULL.
+should be
+.B NONNULL ,
+even no option value is to be supplied or returned.
 .PP
 .I Optname
 and any specified options are passed uninterpreted to the appropriate
-- 
2.41.0.rc0.172.g3f132b7071-goog


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux