Re: [PATCH] Fix the man page of setsockopt.2

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

 



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: OpenPGP_signature
Description: OpenPGP digital signature


[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