* [PATCH] getsockname.2: Use restrict in prototypes
@ 2021-02-03 21:25 Alejandro Colomar
2021-02-03 21:31 ` Alejandro Colomar (man-pages)
0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2021-02-03 21:25 UTC (permalink / raw)
To: mtk.manpages
Cc: Alejandro Colomar, linux-man, libc-alpha, Heinrich Schuchardt
POSIX specifies that the 2nd and 3rd parameters to getsockname()
shall be 'restrict'. Glibc uses 'restrict' too.
Let's use it here too.
......
.../glibc$ grep_syscall_wrapper getsockname
socket/sys/socket.h:116:
extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
socklen_t *__restrict __len) __THROW;
.../glibc$ grep -rn '# *define __SOCKADDR_ARG'
socket/sys/socket.h:58:
# define __SOCKADDR_ARG struct sockaddr *__restrict
.../glibc$
function grep_syscall_wrapper()
{
if ! [ -v 1 ]; then
>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
return ${EX_USAGE};
fi
find * -type f \
|grep '\.h$' \
|sort -V \
|xargs pcregrep -Mn \
"(?s)^[^\s#][\w\s]+\s+\**${1}\s*\([\w\s()[\]*,]*?(...)?\)[\w\s()]*;" \
|sed -E 's/^[^:]+:[0-9]+:/&\n/';
}
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
man2/getsockname.2 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/man2/getsockname.2 b/man2/getsockname.2
index 55db4b84c..034c9d4ac 100644
--- a/man2/getsockname.2
+++ b/man2/getsockname.2
@@ -44,8 +44,8 @@ getsockname \- get socket name
.nf
.B #include <sys/socket.h>
.PP
-.BI "int getsockname(int " sockfd ", struct sockaddr *" addr \
-", socklen_t *" addrlen );
+.BI "int getsockname(int " sockfd ", struct sockaddr *" addr ,
+.BI " socklen_t *restrict " addrlen );
.fi
.SH DESCRIPTION
.BR getsockname ()
--
2.30.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] getsockname.2: Use restrict in prototypes
2021-02-03 21:25 [PATCH] getsockname.2: Use restrict in prototypes Alejandro Colomar
@ 2021-02-03 21:31 ` Alejandro Colomar (man-pages)
2021-02-03 21:36 ` [PATCH v2] " Alejandro Colomar
0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-02-03 21:31 UTC (permalink / raw)
To: mtk.manpages; +Cc: linux-man, libc-alpha, Heinrich Schuchardt
On 2/3/21 10:25 PM, Alejandro Colomar wrote:
> POSIX specifies that the 2nd and 3rd parameters to getsockname()
> shall be 'restrict'. Glibc uses 'restrict' too.
> Let's use it here too.
>
> ......
>
> .../glibc$ grep_syscall_wrapper getsockname
> socket/sys/socket.h:116:
> extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
> socklen_t *__restrict __len) __THROW;
> .../glibc$ grep -rn '# *define __SOCKADDR_ARG'
> socket/sys/socket.h:58:
> # define __SOCKADDR_ARG struct sockaddr *__restrict
> .../glibc$
>
> function grep_syscall_wrapper()
> {
> if ! [ -v 1 ]; then
> >&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
> return ${EX_USAGE};
> fi
>
> find * -type f \
> |grep '\.h$' \
> |sort -V \
> |xargs pcregrep -Mn \
> "(?s)^[^\s#][\w\s]+\s+\**${1}\s*\([\w\s()[\]*,]*?(...)?\)[\w\s()]*;" \
> |sed -E 's/^[^:]+:[0-9]+:/&\n/';
> }
>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Hi Michael,
I forgot to actually add restrict to one of the parameters.
Wait for v2 :)
Cheers,
Alex
> ---
> man2/getsockname.2 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/man2/getsockname.2 b/man2/getsockname.2
> index 55db4b84c..034c9d4ac 100644
> --- a/man2/getsockname.2
> +++ b/man2/getsockname.2
> @@ -44,8 +44,8 @@ getsockname \- get socket name
> .nf
> .B #include <sys/socket.h>
> .PP
> -.BI "int getsockname(int " sockfd ", struct sockaddr *" addr \
> -", socklen_t *" addrlen );
> +.BI "int getsockname(int " sockfd ", struct sockaddr *" addr ,
> +.BI " socklen_t *restrict " addrlen );
> .fi
> .SH DESCRIPTION
> .BR getsockname ()
>
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] getsockname.2: Use restrict in prototypes
2021-02-03 21:31 ` Alejandro Colomar (man-pages)
@ 2021-02-03 21:36 ` Alejandro Colomar
2021-02-06 20:40 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2021-02-03 21:36 UTC (permalink / raw)
To: mtk.manpages
Cc: Alejandro Colomar, linux-man, libc-alpha, Heinrich Schuchardt
POSIX specifies that the 2nd and 3rd parameters to getsockname()
shall be 'restrict'. Glibc uses 'restrict' too.
Let's use it here too.
......
.../glibc$ grep_syscall_wrapper getsockname
socket/sys/socket.h:116:
extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
socklen_t *__restrict __len) __THROW;
.../glibc$ grep -rn '# *define __SOCKADDR_ARG'
socket/sys/socket.h:58:
# define __SOCKADDR_ARG struct sockaddr *__restrict
.../glibc$
function grep_syscall_wrapper()
{
if ! [ -v 1 ]; then
>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
return ${EX_USAGE};
fi
find * -type f \
|grep '\.h$' \
|sort -V \
|xargs pcregrep -Mn \
"(?s)^[^\s#][\w\s]+\s+\**${1}\s*\([\w\s()[\]*,]*?(...)?\)[\w\s()]*;" \
|sed -E 's/^[^:]+:[0-9]+:/&\n/';
}
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
v2: Add restrict to 2nd param.
man2/getsockname.2 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/man2/getsockname.2 b/man2/getsockname.2
index 55db4b84c..bf36e260b 100644
--- a/man2/getsockname.2
+++ b/man2/getsockname.2
@@ -44,8 +44,8 @@ getsockname \- get socket name
.nf
.B #include <sys/socket.h>
.PP
-.BI "int getsockname(int " sockfd ", struct sockaddr *" addr \
-", socklen_t *" addrlen );
+.BI "int getsockname(int " sockfd ", struct sockaddr *restrict " addr ,
+.BI " socklen_t *restrict " addrlen );
.fi
.SH DESCRIPTION
.BR getsockname ()
--
2.30.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] getsockname.2: Use restrict in prototypes
2021-02-03 21:36 ` [PATCH v2] " Alejandro Colomar
@ 2021-02-06 20:40 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-02-06 20:40 UTC (permalink / raw)
To: Alejandro Colomar
Cc: mtk.manpages, linux-man, libc-alpha, Heinrich Schuchardt
On 2/3/21 10:36 PM, Alejandro Colomar wrote:
> POSIX specifies that the 2nd and 3rd parameters to getsockname()
> shall be 'restrict'. Glibc uses 'restrict' too.
> Let's use it here too.
Thanks, Alex. Patch applied.
Cheers,
Michael
>
> ......
>
> .../glibc$ grep_syscall_wrapper getsockname
> socket/sys/socket.h:116:
> extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
> socklen_t *__restrict __len) __THROW;
> .../glibc$ grep -rn '# *define __SOCKADDR_ARG'
> socket/sys/socket.h:58:
> # define __SOCKADDR_ARG struct sockaddr *__restrict
> .../glibc$
>
> function grep_syscall_wrapper()
> {
> if ! [ -v 1 ]; then
> >&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
> return ${EX_USAGE};
> fi
>
> find * -type f \
> |grep '\.h$' \
> |sort -V \
> |xargs pcregrep -Mn \
> "(?s)^[^\s#][\w\s]+\s+\**${1}\s*\([\w\s()[\]*,]*?(...)?\)[\w\s()]*;" \
> |sed -E 's/^[^:]+:[0-9]+:/&\n/';
> }
>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
>
> v2: Add restrict to 2nd param.
>
> man2/getsockname.2 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/man2/getsockname.2 b/man2/getsockname.2
> index 55db4b84c..bf36e260b 100644
> --- a/man2/getsockname.2
> +++ b/man2/getsockname.2
> @@ -44,8 +44,8 @@ getsockname \- get socket name
> .nf
> .B #include <sys/socket.h>
> .PP
> -.BI "int getsockname(int " sockfd ", struct sockaddr *" addr \
> -", socklen_t *" addrlen );
> +.BI "int getsockname(int " sockfd ", struct sockaddr *restrict " addr ,
> +.BI " socklen_t *restrict " addrlen );
> .fi
> .SH DESCRIPTION
> .BR getsockname ()
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-06 20:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 21:25 [PATCH] getsockname.2: Use restrict in prototypes Alejandro Colomar
2021-02-03 21:31 ` Alejandro Colomar (man-pages)
2021-02-03 21:36 ` [PATCH v2] " Alejandro Colomar
2021-02-06 20:40 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).