Hi Alejandro, yes, that's what needs to fix. The documentation for setsockopt() in https://man7.org/linux/man-pages/man2/setsockopt.2.html, the documentation for getsockopt(2) should be more clear. The value in getsockopt() may be NULL, but value in setsockopt() must be NONNULL due to reasons listed in the previous emails. I update the fix (see in the attached patch). Thank you! Best, Zijun On Wed, May 31, 2023 at 1:29 PM Alejandro Colomar <alx.manpages@xxxxxxxxx> wrote: > > Hi Zijun! > > On 5/31/23 20:19, Zijun Zhao wrote: > > 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 > > That patch you're sending modifies the documentation for getsockopt(2), > not setsockopt(2). Please revise. > > > diff --git a/man2/getsockopt.2 b/man2/getsockopt.2 > > index a0cda8e87..28059793a 100644 > > --- a/man2/getsockopt.2 > > +++ b/man2/getsockopt.2 > > @@ -70,23 +70,24 @@ .SH DESCRIPTION > > they identify a buffer in which the value for the > > requested option(s) are to be returned. > > For > > .BR getsockopt (), > > .I optlen > > is a value-result argument, initially containing the > > 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 > > protocol module for interpretation. > > The include file > > .I <sys/socket.h> > > contains definitions for socket level options, described below. > > Options at > > other protocol levels vary in format and name; consult the appropriate > > entries in section 4 of the manual. > > Cheers, > Alex > > -- > <http://www.alejandro-colomar.es/> > GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
Attachment:
changes.patch
Description: Binary data