Skip to contentSkip to conversation

man3: SYNOPSIS: Use 'restrict' in prototypes (batch 5)

PATCH In review Alejandro Colomar 2 participants 29 messages Mar 10, 2021 – Mar 19, 2021 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

cover man3: SYNOPSIS: Use 'restrict' in prototypes (batch 5)

This fixes up til trunc.3 (I didn't send you scanf.3
in this patch set because I did in my mom's computer and forgot to push).

When you come back and merge all of the pending patches, I'll send/resend anything that's not in sync anyway.
So don't worry about missing some of them.

Kind regards,

Alex

Alejandro Colomar (24):
sem_getvalue.3: SYNOPSIS: Use 'restrict' in prototypes sem_wait.3: SYNOPSIS: Use 'restrict' in prototypes setaliasent.3: SYNOPSIS: Use 'restrict' in prototypes setbuf.3: SYNOPSIS: Use 'restrict' in prototypes setbuf.3: SYNOPSIS: Use 'restrict' in prototypes setnetgrent.3: SYNOPSIS: Use 'restrict' in prototypes sigwait.3: SYNOPSIS: Use 'restrict' in prototypes statvfs.3: SYNOPSIS: Use 'restrict' in prototypes stpcpy.3: SYNOPSIS: Use 'restrict' in prototypes stpncpy.3: SYNOPSIS: Use 'restrict' in prototypes strcat.3: SYNOPSIS: Use 'restrict' in prototypes strcpy.3: SYNOPSIS: Use 'restrict' in prototypes strfmon.3: SYNOPSIS: Use 'restrict' in prototypes strftime.3: SYNOPSIS: Use 'restrict' in prototypes string.3: SYNOPSIS: Use 'restrict' in prototypes string.3: SYNOPSIS: Use 'restrict' in prototypes strptime.3: SYNOPSIS: Use 'restrict' in prototypes strsep.3: SYNOPSIS: Use 'restrict' in prototypes strtod.3: SYNOPSIS: Use 'restrict' in prototypes strtoimax.3: SYNOPSIS: Use 'restrict' in prototypes strtok.3: SYNOPSIS: Use 'restrict' in prototypes strtol.3, strtoul.3: SYNOPSIS: Use 'restrict' in prototypes strxfrm.3: SYNOPSIS: Use 'restrict' in prototypes swab.3: SYNOPSIS: Use 'restrict' in prototypes

 man3/sem_getvalue.3 |  2 +-
 man3/sem_wait.3     |  3 ++-
 man3/setaliasent.3  | 13 +++++++------
 man3/setbuf.3       |  9 +++++----
 man3/setnetgrent.3  | 12 +++++++-----
 man3/sigwait.3      |  2 +-
 man3/statvfs.3      |  3 ++-
 man3/stpcpy.3       |  2 +-
 man3/stpncpy.3      |  3 ++-
 man3/strcat.3       |  5 +++--
 man3/strcpy.3       |  5 +++--
 man3/strfmon.3      |  7 ++++---
 man3/strftime.3     |  5 +++--
 man3/string.3       | 21 ++++++++++++---------
 man3/strptime.3     |  3 ++-
 man3/strsep.3       |  2 +-
 man3/strtod.3       |  7 ++++---
 man3/strtoimax.3    |  6 ++++--
 man3/strtok.3       |  5 +++--
 man3/strtol.3       |  7 ++++---
 man3/strtoul.3      |  8 ++++----
 man3/strxfrm.3      |  3 ++-
 man3/swab.3         |  3 ++-
 23 files changed, 79 insertions(+), 57 deletions(-)
Signature · 1 line
2.30.1.721.g45526154a5
#1 lore raw

PATCH 1/24 sem_getvalue.3: SYNOPSIS: Use 'restrict' in prototypes

Both POSIX and glibc use 'restrict' in sem_getvalue(). Let's use it here too.

.../glibc$ grep_glibc_prototype sem_getvalue sysdeps/pthread/semaphore.h:81:
extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
__THROW __nonnull ((1, 2));
.../glibc$

---
 man3/sem_getvalue.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/sem_getvalue.3 +1 -1
index ddfb1899a..084dc510d 100644
@@ -29,7 +29,7 @@ sem_getvalue \- get the value of a semaphore
 .nf
 .B #include <semaphore.h>
 .PP
-.BI "int sem_getvalue(sem_t *" sem ", int *" sval );
+.BI "int sem_getvalue(sem_t *restrict " sem ", int *restrict " sval );
 .fi
 .PP
 Link with \fI\-pthread\fP.
Signature · 1 line
2.30.1.721.g45526154a5
#2 lore raw

PATCH 2/24 sem_wait.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in sem_timedwait(). Let's use it here too.

.../glibc$ grep_glibc_prototype sem_timedwait sysdeps/pthread/semaphore.h:62:
extern int sem_timedwait (sem_t *__restrict __sem,
const struct timespec *__restrict __abstime)
__nonnull ((1, 2));
.../glibc$

---
 man3/sem_wait.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/sem_wait.3 +2 -1
index d57b6f6ce..da7ae72c2 100644
@@ -31,7 +31,8 @@ sem_wait, sem_timedwait, sem_trywait \- lock a semaphore
 .PP
 .BI "int sem_wait(sem_t *" sem );
 .BI "int sem_trywait(sem_t *" sem );
-.BI "int sem_timedwait(sem_t *" sem ", const struct timespec *" abs_timeout );
+.BI "int sem_timedwait(sem_t *restrict " sem ,
+.BI "                  const struct timespec *restrict " abs_timeout );
 .fi
 .PP
 Link with \fI\-pthread\fP.
Signature · 1 line
2.30.1.721.g45526154a5
#3 lore raw

PATCH 3/24 setaliasent.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in getaliasent_r(), getaliasbyname_r(). Let's use it here too.

.../glibc$ grep_glibc_prototype getaliasent_r inet/aliases.h:48:
extern int getaliasent_r (struct aliasent *__restrict __result_buf,

			  char *__restrict __buffer, size_t __buflen,
			  struct aliasent **__restrict __result) __THROW;

.../glibc$ grep_glibc_prototype getaliasbyname_r inet/aliases.h:56:
extern int getaliasbyname_r (const char *__restrict __name,
struct aliasent *__restrict __result_buf, char *__restrict __buffer, size_t __buflen, struct aliasent **__restrict __result) __THROW;
.../glibc$

---
 man3/setaliasent.3 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
man3/setaliasent.3 +7 -6
index 027bc91b6..b1b3a4ae5 100644
@@ -18,14 +18,15 @@ getaliasbyname, getaliasbyname_r \- read an alias entry
 .B "void endaliasent(void);"
 .PP
 .B "struct aliasent *getaliasent(void);"
-.BI "int getaliasent_r(struct aliasent *" result ","
-.BI "               char *" buffer ", size_t " buflen \
-", struct aliasent **" res );
+.BI "int getaliasent_r(struct aliasent *restrict " result ,
+.BI "                     char *restrict " buffer ", size_t " buflen ,
+.BI "                     struct aliasent **restrict " res );
 .PP
 .BI "struct aliasent *getaliasbyname(const char *" name );
-.BI "int getaliasbyname_r(const char *" name ", struct aliasent *" result ,
-.BI "               char *" buffer ", size_t " buflen \
-", struct aliasent **" res );
+.BI "int getaliasbyname_r(const char *restrict " name ,
+.BI "                     struct aliasent *restrict " result ,
+.BI "                     char *restrict " buffer ", size_t " buflen ,
+.BI "                     struct aliasent **restrict " res );
 .fi
 .SH DESCRIPTION
 One of the databases available with the Name Service Switch (NSS)
Signature · 1 line
2.30.1.721.g45526154a5
#4 lore raw

PATCH 4/24 setbuf.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in setbuffer().
Let's use it here too.

.../glibc$ grep_glibc_prototype setbuffer
libio/stdio.h:314:
extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,

		       size_t __size) __THROW;

.../glibc$

---
 man3/setbuf.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/setbuf.3 +2 -1
index ccfeb83ba..ac73bb06e 100644
@@ -56,7 +56,8 @@ setbuf, setbuffer, setlinebuf, setvbuf \- stream buffering operations
 ", size_t " size );
 .PP
 .BI "void setbuf(FILE *" stream ", char *" buf );
-.BI "void setbuffer(FILE *" stream ", char *" buf ", size_t "  size );
+.BI "void setbuffer(FILE *restrict " stream ", char *restrict " buf ,
+.BI "            size_t "  size );
 .BI "void setlinebuf(FILE *" stream );
 .fi
 .PP
Signature · 1 line
2.30.1.721.g45526154a5
#5 lore raw

PATCH 5/24 setbuf.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in setvbuf(), setbuf(). Let's use it here too.

.../glibc$ grep_glibc_prototype setvbuf
libio/stdio.h:308:
extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,

		    int __modes, size_t __n) __THROW;

.../glibc$ grep_glibc_prototype setbuf
libio/stdio.h:304:
extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW; .../glibc$

---
 man3/setbuf.3 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
man3/setbuf.3 +3 -3
index ac73bb06e..708e5c5aa 100644
@@ -52,10 +52,10 @@ setbuf, setbuffer, setlinebuf, setvbuf \- stream buffering operations
 .nf
 .B #include <stdio.h>
 .PP
-.BI "int setvbuf(FILE *" stream ", char *" buf ", int " mode \
-", size_t " size );
+.BI "int setvbuf(FILE *restrict " stream ", char *restrict " buf ,
+.BI "            int " mode ", size_t " size );
 .PP
-.BI "void setbuf(FILE *" stream ", char *" buf );
+.BI "void setbuf(FILE *restrict " stream ", char *restrict " buf );
 .BI "void setbuffer(FILE *restrict " stream ", char *restrict " buf ,
 .BI "            size_t "  size );
 .BI "void setlinebuf(FILE *" stream );
Signature · 1 line
2.30.1.721.g45526154a5
#6 lore raw

PATCH 6/24 setnetgrent.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in getnetgrent(), getnetgrent_r(). Let's use it here too.

.../glibc$ grep_glibc_prototype getnetgrent resolv/netdb.h:410:
extern int getnetgrent (char **__restrict __hostp,

			char **__restrict __userp,
			char **__restrict __domainp);
.../glibc$ grep_glibc_prototype getnetgrent_r
resolv/netdb.h:430:
extern int getnetgrent_r (char **__restrict __hostp,
			  char **__restrict __userp,
			  char **__restrict __domainp,
			  char *__restrict __buffer, size_t __buflen);

.../glibc$

---
 man3/setnetgrent.3 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
man3/setnetgrent.3 +7 -5
index 440cf2846..2a783ee58 100644
@@ -18,12 +18,14 @@ handle network group entries
 .BI "int setnetgrent(const char *" netgroup );
 .B "void endnetgrent(void);"
 .PP
-.BI "int getnetgrent(char **" host ", char **" user ", char **" domain );
-.BI "int getnetgrent_r(char **" host ", char **" user ","
-.BI "                  char **" domain ", char *" buf ", size_t " buflen );
+.BI "int getnetgrent(char **restrict " host ,
+.BI "            char **restrict " user ", char **restrict " domain );
+.BI "int getnetgrent_r(char **restrict " host ,
+.BI "            char **restrict " user ", char **restrict " domain ,
+.BI "            char *restrict " buf ", size_t " buflen );
 .PP
-.BI "int innetgr(const char *" netgroup ", const char *" host ","
-.BI "                  const char *" user ", const char *" domain );
+.BI "int innetgr(const char *" netgroup ", const char *" host ,
+.BI "            const char *" user ", const char *" domain );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#7 lore raw

PATCH 7/24 sigwait.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in sigwait().
Let's use it here too.

.../glibc$ grep_glibc_prototype sigwait
signal/signal.h:255:
extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)

     __nonnull ((1, 2));

.../glibc$

---
 man3/sigwait.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/sigwait.3 +1 -1
index 47c79a24d..30b7af568 100644
@@ -30,7 +30,7 @@ sigwait \- wait for a signal
 .nf
 .B #include <signal.h>
 .PP
-.BI "int sigwait(const sigset_t *" set ", int *" sig );
+.BI "int sigwait(const sigset_t *restrict " set ", int *restrict " sig );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#8 lore raw

PATCH 8/24 statvfs.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in statvfs().
Let's use it here too.

.../glibc$ grep_glibc_prototype statvfs io/sys/statvfs.h:51:
extern int statvfs (const char *__restrict __file,

		    struct statvfs *__restrict __buf)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/statvfs.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/statvfs.3 +2 -1
index 4f2788614..6fbfdc719 100644
@@ -34,7 +34,8 @@ statvfs, fstatvfs \- get filesystem statistics
 .nf
 .B #include <sys/statvfs.h>
 .PP
-.BI "int statvfs(const char *" path ", struct statvfs *" buf );
+.BI "int statvfs(const char *restrict " path \
+", struct statvfs *restrict " buf );
 .BI "int fstatvfs(int " fd ", struct statvfs *" buf );
 .fi
 .SH DESCRIPTION
Signature · 1 line
2.30.1.721.g45526154a5
#9 lore raw

PATCH 9/24 stpcpy.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in stpcpy().
Let's use it here too.

.../glibc$ grep_glibc_prototype stpcpy
string/string.h:475:
extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)

     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/stpcpy.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/stpcpy.3 +1 -1
index 448b53955..e978dfb3e 100644
@@ -29,7 +29,7 @@ stpcpy \- copy a string returning a pointer to its end
 .nf
 .B #include <string.h>
 .PP
-.BI "char *stpcpy(char *" dest ", const char *" src );
+.BI "char *stpcpy(char *restrict " dest ", const char *restrict " src );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#10 lore raw

PATCH 10/24 stpncpy.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in stpncpy().
Let's use it here too.

.../glibc$ grep_glibc_prototype stpncpy
string/string.h:483:
extern char *stpncpy (char *__restrict __dest,

		      const char *__restrict __src, size_t __n)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/stpncpy.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/stpncpy.3 +2 -1
index 3adc5f426..493d42378 100644
@@ -18,7 +18,8 @@ stpncpy \- copy a fixed-size string, returning a pointer to its end
 .nf
 .B #include <string.h>
 .PP
-.BI "char *stpncpy(char *" dest ", const char *" src ", size_t " n );
+.BI "char *stpncpy(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#11 lore raw

PATCH 11/24 strcat.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strcat(), strncat(). Let's use it here too.

.../glibc$ grep_glibc_prototype strcat
string/string.h:133:
extern char *strcat (char *__restrict __dest, const char *__restrict __src)

     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strncat
string/string.h:136:
extern char *strncat (char *__restrict __dest, const char *__restrict __src,
		      size_t __n) __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/strcat.3 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
man3/strcat.3 +3 -2
index d8e6716c4..821d57d74 100644
@@ -36,8 +36,9 @@ strcat, strncat \- concatenate two strings
 .nf
 .B #include <string.h>
 .PP
-.BI "char *strcat(char *" dest ", const char *" src );
-.BI "char *strncat(char *" dest ", const char *" src ", size_t " n );
+.BI "char *strcat(char *restrict " dest ", const char *restrict " src );
+.BI "char *strncat(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#12 lore raw

PATCH 12/24 strcpy.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strcpy(), strncpy(). Let's use it here too.

.../glibc$ grep_glibc_prototype strcpy
string/string.h:125:
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)

     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strncpy
string/string.h:128:
extern char *strncpy (char *__restrict __dest,
		      const char *__restrict __src, size_t __n)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/strcpy.3 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
man3/strcpy.3 +3 -2
index 46993cdb3..ade8b9412 100644
@@ -39,8 +39,9 @@ strcpy, strncpy \- copy a string
 .nf
 .B #include <string.h>
 .PP
-.BI "char *strcpy(char *" dest ", const char *" src );
-.BI "char *strncpy(char *" dest ", const char *" src ", size_t " n );
+.BI "char *strcpy(char *restrict " dest ", const char *" src );
+.BI "char *strncpy(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#13 lore raw

PATCH 13/24 strfmon.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strfmon(), strfmon_l(). Let's use it here too.

.../glibc$ grep_glibc_prototype strfmon stdlib/monetary.h:38:
extern ssize_t strfmon (char *__restrict __s, size_t __maxsize,

			const char *__restrict __format, ...)
     __THROW __attribute_format_strfmon__ (3, 4);
.../glibc$ grep_glibc_prototype strfmon_l
stdlib/monetary.h:47:
extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
			  locale_t __loc,
			  const char *__restrict __format, ...)
     __THROW __attribute_format_strfmon__ (4, 5);

.../glibc$

---
 man3/strfmon.3 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
man3/strfmon.3 +4 -3
index f2434a7fa..98c8d34fe 100644
@@ -28,9 +28,10 @@ strfmon, strfmon_l \- convert monetary value to a string
 .nf
 .B #include <monetary.h>
 .PP
-.BI "ssize_t strfmon(char *" s ", size_t " max ", const char *" format ", ...);"
-.BI "ssize_t strfmon_l(char *" s ", size_t " max ", locale_t " locale ,
-.BI "                  const char *" format ", ...);"
+.BI "ssize_t strfmon(char *restrict " s ", size_t " max ,
+.BI "                const char *restrict " format ", ...);"
+.BI "ssize_t strfmon_l(char *restrict " s ", size_t " max ", locale_t " locale ,
+.BI "                const char *restrict " format ", ...);"
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#14 lore raw

PATCH 14/24 strftime.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strftime(). Let's use it here too.

.../glibc$ grep_glibc_prototype strftime timezone/private.h:506:
size_t strftime(char *restrict, size_t, char const *restrict,

		struct tm const *restrict);
time/time.h:88:
extern size_t strftime (char *__restrict __s, size_t __maxsize,
			const char *__restrict __format,
			const struct tm *__restrict __tp) __THROW;

.../glibc$

---
 man3/strftime.3 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
man3/strftime.3 +3 -2
index e49465f29..6b14b7c5d 100644
@@ -41,8 +41,9 @@ strftime \- format date and time
 .nf
 .B #include <time.h>
 .PP
-.BI "size_t strftime(char *" s ", size_t " max ", const char *" format ,
-.BI "                const struct tm *" tm );
+.BI "size_t strftime(char *restrict " s ", size_t " max ,
+.BI "                const char *restrict " format ,
+.BI "                const struct tm *restrict " tm );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#15 lore raw

PATCH 15/24 string.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in stpcpy(), strcat(), strcpy(), strncat(), strncpy(), strtok(), strxfrm(). Let's use it here too.

.../glibc$ grep_glibc_prototype stpcpy
string/string.h:475:
extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)

     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strcat
string/string.h:133:
extern char *strcat (char *__restrict __dest, const char *__restrict __src)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strcpy
string/string.h:125:
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strncat
string/string.h:136:
extern char *strncat (char *__restrict __dest, const char *__restrict __src,
		      size_t __n) __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strncpy
string/string.h:128:
extern char *strncpy (char *__restrict __dest,
		      const char *__restrict __src, size_t __n)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strtok
string/string.h:340:
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
     __THROW __nonnull ((2));
.../glibc$ grep_glibc_prototype strxfrm
string/string.h:150:
extern size_t strxfrm (char *__restrict __dest,
		       const char *__restrict __src, size_t __n)
    __THROW __nonnull ((2)) __attr_access ((__write_only__, 1, 3));

.../glibc$

---
 man3/string.3 | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
man3/string.3 +11 -8
index ab4cc3ce7..06da21c28 100644
@@ -66,7 +66,7 @@ in the string
 .TP
 .B #include <string.h>
 .TP
-.BI "char *stpcpy(char *" dest ", const char *" src );
+.BI "char *stpcpy(char *restrict " dest ", const char *restrict " src );
 Copy a string from
 .I src
 to
@@ -74,7 +74,7 @@ to
 returning a pointer to the end of the resulting string at
 .IR dest .
 .TP
-.BI "char *strcat(char *" dest ", const char *" src );
+.BI "char *strcat(char *restrict " dest ", const char *restrict " src );
 Append the string
 .I src
 to the string
@@ -101,7 +101,7 @@ with
 .I s2
 using the current locale.
 .TP
-.BI "char *strcpy(char *" dest ", const char *" src );
+.BI "char *strcpy(char *restrict " dest ", const char *restrict " src );
 Copy the string
 .I src
 to
@@ -129,7 +129,8 @@ Randomly swap the characters in
 Return the length of the string
 .IR s .
 .TP
-.BI "char *strncat(char *" dest ", const char *" src ", size_t " n );
+.BI "char *strncat(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 Append at most
 .I n
 bytes from the string
@@ -147,7 +148,8 @@ bytes of the strings
 and
 .IR s2 .
 .TP
-.BI "char *strncpy(char *" dest ", const char *" src ", size_t " n );
+.BI "char *strncpy(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 Copy at most
 .I n
 bytes from string
@@ -188,19 +190,20 @@ in the string
 .IR haystack ,
 returning a pointer to the found substring.
 .TP
-.BI "char *strtok(char *" s ", const char *" delim );
+.BI "char *strtok(char *restrict " s ", const char *restrict " delim );
 Extract tokens from the string
 .I s
 that are delimited by one of the bytes in
 .IR delim .
 .TP
-.BI "size_t strxfrm(char *" dest ", const char *" src ", size_t " n );
+.BI "size_t strxfrm(char *restrict " dst ", const char *restrict " src \
+", size_t " n );
 Transforms
 .I src
 to the current locale and copies the first
 .I n
 bytes to
-.IR dest .
+.IR dst .
 .SH DESCRIPTION
 The string functions perform operations on null-terminated
 strings.
Signature · 1 line
2.30.1.721.g45526154a5
#16 lore raw

PATCH 16/24 string.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in strsep().
Let's use it here too.

.../glibc$ grep_glibc_prototype strsep
string/string.h:455:
extern char *strsep (char **__restrict __stringp,

		     const char *__restrict __delim)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/string.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/string.3 +1 -1
index 06da21c28..4bacd8d8b 100644
@@ -171,7 +171,7 @@ Return a pointer to the last occurrence of the character
 in the string
 .IR s .
 .TP
-.BI "char *strsep(char **" stringp ", const char *" delim );
+.BI "char *strsep(char **restrict " stringp ", const char *restrict " delim );
 Extract the initial token in
 .I stringp
 that is delimited by one of the bytes in
Signature · 1 line
2.30.1.721.g45526154a5
#17 lore raw

PATCH 17/24 strptime.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strptime(). However, glibc doesn't specify 'restrict' for the last parameter. Let's use the most restrictive form here
(although I believe both to be equivalent).

.../glibc$ grep_glibc_prototype strptime time/time.h:95:
extern char *strptime (const char *__restrict __s,

		       const char *__restrict __fmt, struct tm *__tp)
     __THROW;

.../glibc$

---
 man3/strptime.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/strptime.3 +2 -1
index c1a66ffc0..30c6f59df 100644
@@ -36,7 +36,8 @@ strptime \- convert a string representation of time to a time tm structure
 .BR "#define _XOPEN_SOURCE" "       /* See feature_test_macros(7) */"
 .B #include <time.h>
 .PP
-.BI "char *strptime(const char *" s ", const char *" format ", struct tm *" tm );
+.BI "char *strptime(const char *restrict " s ", const char *restrict " format ,
+.BI "               struct tm *restrict " tm );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#18 lore raw

PATCH 18/24 strsep.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in strsep().
Let's use it here too.

.../glibc$ grep_glibc_prototype strsep
string/string.h:455:
extern char *strsep (char **__restrict __stringp,

		     const char *__restrict __delim)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/strsep.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/strsep.3 +1 -1
index 9d40e208b..91c379bdb 100644
@@ -37,7 +37,7 @@ strsep \- extract token from string
 .nf
 .B #include <string.h>
 .PP
-.BI "char *strsep(char **" stringp ", const char *" delim );
+.BI "char *strsep(char **restrict " stringp ", const char *restrict " delim );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#19 lore raw

PATCH 19/24 strtod.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strtod(), strtof(), strtold(). Let's use it here too.

.../glibc$ grep_glibc_prototype strtod stdlib/stdlib.h:117:
extern double strtod (const char *__restrict __nptr,

		      char **__restrict __endptr)
     __THROW __nonnull ((1));
.../glibc$ grep_glibc_prototype strtof
stdlib/stdlib.h:123:
extern float strtof (const char *__restrict __nptr,
		     char **__restrict __endptr) __THROW __nonnull ((1));
.../glibc$ grep_glibc_prototype strtold
stdlib/stdlib.h:126:
extern long double strtold (const char *__restrict __nptr,
			    char **__restrict __endptr)
     __THROW __nonnull ((1));

.../glibc$

---
 man3/strtod.3 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
man3/strtod.3 +4 -3
index e77bd59ec..24cb4ad13 100644
@@ -49,9 +49,10 @@ strtod, strtof, strtold \- convert ASCII string to floating-point number
 .nf
 .B #include <stdlib.h>
 .PP
-.BI "double strtod(const char *" nptr ", char **" endptr );
-.BI "float strtof(const char *" nptr ", char **" endptr );
-.BI "long double strtold(const char *" nptr ", char **" endptr );
+.BI "double strtod(const char *restrict " nptr ", char **restrict " endptr );
+.BI "float strtof(const char *restrict " nptr ", char **restrict " endptr );
+.BI "long double strtold(const char *restrict " nptr \
+", char **restrict " endptr );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#20 lore raw

PATCH 20/24 strtoimax.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strtoimax(), strtoumax(). Let's use it here too.

.../glibc$ grep_glibc_prototype strtoimax stdlib/inttypes.h:297:
extern intmax_t strtoimax (const char *__restrict __nptr,

			   char **__restrict __endptr, int __base) __THROW;
.../glibc$ grep_glibc_prototype strtoumax
stdlib/inttypes.h:301:
extern uintmax_t strtoumax (const char *__restrict __nptr,
			    char ** __restrict __endptr, int __base) __THROW;

.../glibc$

---
 man3/strtoimax.3 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
man3/strtoimax.3 +4 -2
index 9acaa1244..6c14c6ac8 100644
@@ -28,8 +28,10 @@ strtoimax, strtoumax \- convert string to integer
 .nf
 .B #include <inttypes.h>
 .PP
-.BI "intmax_t strtoimax(const char *" nptr ", char **" endptr ", int " base );
-.BI "uintmax_t strtoumax(const char *" nptr ", char **" endptr ", int " base );
+.BI "intmax_t strtoimax(const char *restrict " nptr ", char **restrict " endptr ,
+.BI "                   int " base );
+.BI "uintmax_t strtoumax(const char *restrict " nptr ", char **restrict " endptr ,
+.BI "                   int " base );
 .fi
 .SH DESCRIPTION
 These functions are just like
Signature · 1 line
2.30.1.721.g45526154a5
#21 lore raw

PATCH 21/24 strtok.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strtok(), strtok_r(). Let's use it here too.

.../glibc$ grep_glibc_prototype strtok
string/string.h:340:
extern char *strtok (char *__restrict __s, const char *__restrict __delim)

     __THROW __nonnull ((2));
.../glibc$ grep_glibc_prototype strtok_r
string/string.h:350:
extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
		       char **__restrict __save_ptr)
     __THROW __nonnull ((2, 3));

.../glibc$

---
 man3/strtok.3 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
man3/strtok.3 +3 -2
index 6db48b677..8058ff2fe 100644
@@ -36,8 +36,9 @@ strtok, strtok_r \- extract tokens from strings
 .nf
 .B #include <string.h>
 .PP
-.BI "char *strtok(char *" str ", const char *" delim );
-.BI "char *strtok_r(char *" str ", const char *" delim ", char **" saveptr );
+.BI "char *strtok(char *restrict " str ", const char *restrict " delim );
+.BI "char *strtok_r(char *restrict " str ", const char *restrict " delim ,
+.BI "               char **restrict " saveptr );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#22 lore raw

PATCH 22/24 strtol.3, strtoul.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strtol(), strtoll(), strtoul(), strtoull(). Let's use it here too.

.../glibc$ grep_glibc_prototype strtol stdlib/stdlib.h:176:
extern long int strtol (const char *__restrict __nptr,

			char **__restrict __endptr, int __base)
     __THROW __nonnull ((1));

.../glibc$ grep_glibc_prototype strtoll stdlib/stdlib.h:199:
__extension__
extern long long int strtoll (const char *__restrict __nptr,

			      char **__restrict __endptr, int __base)
     __THROW __nonnull ((1));
.../glibc$ grep_glibc_prototype strtoul
stdlib/stdlib.h:180:
extern unsigned long int strtoul (const char *__restrict __nptr,
				  char **__restrict __endptr, int __base)
     __THROW __nonnull ((1));

.../glibc$ grep_glibc_prototype strtoull stdlib/stdlib.h:204:
__extension__
extern unsigned long long int strtoull (const char *__restrict __nptr,

					char **__restrict __endptr, int __base)
     __THROW __nonnull ((1));

.../glibc$

---
 man3/strtol.3  | 7 ++++---
 man3/strtoul.3 | 8 ++++----
 2 files changed, 8 insertions(+), 7 deletions(-)
man3/strtol.3 +4 -3
index 8f4a5e54c..148586b99 100644
@@ -36,9 +36,10 @@ strtol, strtoll, strtoq \- convert a string to a long integer
 .nf
 .B #include <stdlib.h>
 .PP
-.BI "long strtol(const char *" nptr ", char **" endptr ", int " base );
-.BI "long long strtoll(const char *" nptr ", char **" endptr \
-", int " base );
+.BI "long strtol(const char *restrict " nptr ,
+.BI "            char **restrict " endptr ", int " base );
+.BI "long long strtoll(const char *restrict " nptr ,
+.BI "            char **restrict " endptr ", int " base );
 .fi
 .PP
 .RS -4
man3/strtoul.3 +4 -4
index b0a5c34fe..c6a55e732 100644
@@ -37,10 +37,10 @@ strtoul, strtoull, strtouq \- convert a string to an unsigned long integer
 .nf
 .B #include <stdlib.h>
 .PP
-.BI "unsigned long strtoul(const char *" nptr ", char **" endptr \
-", int " base );
-.BI "unsigned long long strtoull(const char *" nptr ", char **" endptr ,
-.BI "                            int " base );
+.BI "unsigned long strtoul(const char *restrict " nptr ,
+.BI "                      char **restrict " endptr ", int " base );
+.BI "unsigned long long strtoull(const char *restrict " nptr ,
+.BI "                      char **restrict " endptr ", int " base );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1.721.g45526154a5
#23 lore raw

PATCH 23/24 strxfrm.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in strxfrm().
Let's use it here too.

.../glibc$ grep_glibc_prototype strxfrm
string/string.h:150:
extern size_t strxfrm (char *__restrict __dest,

		       const char *__restrict __src, size_t __n)
    __THROW __nonnull ((2)) __attr_access ((__write_only__, 1, 3));

.../glibc$

---
 man3/strxfrm.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/strxfrm.3 +2 -1
index a6e0e4515..276497450 100644
@@ -34,7 +34,8 @@ strxfrm \- string transformation
 .nf
 .B #include <string.h>
 .PP
-.BI "size_t strxfrm(char *" dest ", const char *" src ", size_t " n );
+.BI "size_t strxfrm(char *restrict " dest ", const char *restrict " src ,
+.BI "               size_t " n );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#24 lore raw

PATCH 24/24 swab.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in swab().
Let's use it here too.

.../glibc$ grep_glibc_prototype swab
posix/unistd.h:1147:
extern void swab (const void *__restrict __from, void *__restrict __to,

		  ssize_t __n) __THROW __nonnull ((1, 2))
    __attr_access ((__read_only__, 1, 3))
    __attr_access ((__write_only__, 2, 3));

.../glibc$

---
 man3/swab.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/swab.3 +2 -1
index b68d698d7..700d2d5f4 100644
@@ -36,7 +36,8 @@ swab \- swap adjacent bytes
 .BR "#define _XOPEN_SOURCE" "       /* See feature_test_macros(7) */"
 .B #include <unistd.h>
 .PP
-.BI "void swab(const void *" from ", void *" to ", ssize_t " n );
+.BI "void swab(const void *restrict " from ", void *restrict " to \
+", ssize_t " n );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1.721.g45526154a5
#25 lore raw
In reply to Alejandro Colomar

Hello Alex,

Quoted 1 line · Alejandro Colomar

This fixes up til trunc.3

trunc.3? I'm a little confused, since the last patch is for swab.3.

Quoted 2 lines

(I didn't send you scanf.3
in this patch set because I did in my mom's computer and forgot to push).

:-).

Quoted 3 lines

When you come back and merge all of the pending patches, I'll send/resend anything that's not in sync anyway.
So don't worry about missing some of them.

I've applied all of the below patches.

Thanks once again for all of this work!

Cheers,

Michael

Quoted 51 lines

Alejandro Colomar (24):
sem_getvalue.3: SYNOPSIS: Use 'restrict' in prototypes sem_wait.3: SYNOPSIS: Use 'restrict' in prototypes setaliasent.3: SYNOPSIS: Use 'restrict' in prototypes setbuf.3: SYNOPSIS: Use 'restrict' in prototypes setbuf.3: SYNOPSIS: Use 'restrict' in prototypes setnetgrent.3: SYNOPSIS: Use 'restrict' in prototypes sigwait.3: SYNOPSIS: Use 'restrict' in prototypes statvfs.3: SYNOPSIS: Use 'restrict' in prototypes stpcpy.3: SYNOPSIS: Use 'restrict' in prototypes stpncpy.3: SYNOPSIS: Use 'restrict' in prototypes strcat.3: SYNOPSIS: Use 'restrict' in prototypes strcpy.3: SYNOPSIS: Use 'restrict' in prototypes strfmon.3: SYNOPSIS: Use 'restrict' in prototypes strftime.3: SYNOPSIS: Use 'restrict' in prototypes string.3: SYNOPSIS: Use 'restrict' in prototypes string.3: SYNOPSIS: Use 'restrict' in prototypes strptime.3: SYNOPSIS: Use 'restrict' in prototypes strsep.3: SYNOPSIS: Use 'restrict' in prototypes strtod.3: SYNOPSIS: Use 'restrict' in prototypes strtoimax.3: SYNOPSIS: Use 'restrict' in prototypes strtok.3: SYNOPSIS: Use 'restrict' in prototypes strtol.3, strtoul.3: SYNOPSIS: Use 'restrict' in prototypes strxfrm.3: SYNOPSIS: Use 'restrict' in prototypes swab.3: SYNOPSIS: Use 'restrict' in prototypes

 man3/sem_getvalue.3 |  2 +-
 man3/sem_wait.3     |  3 ++-
 man3/setaliasent.3  | 13 +++++++------
 man3/setbuf.3       |  9 +++++----
 man3/setnetgrent.3  | 12 +++++++-----
 man3/sigwait.3      |  2 +-
 man3/statvfs.3      |  3 ++-
 man3/stpcpy.3       |  2 +-
 man3/stpncpy.3      |  3 ++-
 man3/strcat.3       |  5 +++--
 man3/strcpy.3       |  5 +++--
 man3/strfmon.3      |  7 ++++---
 man3/strftime.3     |  5 +++--
 man3/string.3       | 21 ++++++++++++---------
 man3/strptime.3     |  3 ++-
 man3/strsep.3       |  2 +-
 man3/strtod.3       |  7 ++++---
 man3/strtoimax.3    |  6 ++++--
 man3/strtok.3       |  5 +++--
 man3/strtol.3       |  7 ++++---
 man3/strtoul.3      |  8 ++++----
 man3/strxfrm.3      |  3 ++-
 man3/swab.3         |  3 ++-
 23 files changed, 79 insertions(+), 57 deletions(-)
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#26 lore raw
Quoted 12 lines · Michael Kerrisk (man-pages)

Hello Alex,

Quoted 1 line · Alejandro Colomar

This fixes up til trunc.3

trunc.3? I'm a little confused, since the last patch is for swab.3.

Quoted 2 lines

(I didn't send you scanf.3
in this patch set because I did in my mom's computer and forgot to push).

:-).

Quoted 7 lines
Quoted 3 lines

When you come back and merge all of the pending patches, I'll send/resend anything that's not in sync anyway.
So don't worry about missing some of them.

I've applied all of the below patches.

Thanks once again for all of this work!

I forgot to mention that you seem to have made a local fix for a small white-space bug in sigwait.3, but didn't send me that patch. Consequently, the sigwait.3 patchy didn't apply until I made the same fix.

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#27 lore raw

Hi Michael,

Quoted 17 lines · Michael Kerrisk (man-pages)
Quoted 16 lines · Michael Kerrisk (man-pages)

Hello Alex,

Quoted 1 line · Alejandro Colomar

This fixes up til trunc.3

trunc.3? I'm a little confused, since the last patch is for swab.3.

Quoted 2 lines

(I didn't send you scanf.3
in this patch set because I did in my mom's computer and forgot to push).

:-).

Quoted 3 lines

When you come back and merge all of the pending patches, I'll send/resend anything that's not in sync anyway.
So don't worry about missing some of them.

Quoted 7 lines
Quoted 3 lines

I've applied all of the below patches.

Thanks once again for all of this work!

I forgot to mention that you seem to have made a local fix for a small white-space bug in sigwait.3, but didn't send me that patch. Consequently, the sigwait.3 patchy didn't apply until I made the same fix.

Yes, when I noticed you weren't able to review all of the emails, I started buffering most of them, so I only sent you the big "trivial" patch sets about restrict, and a few other important patches, to avoid overloading you. While rebasing to reorder them, I lost track of what I had sent you and what not. We'll sync again soon!

Cheers!

Alex

Signature · 3 lines
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
#28 lore raw
In reply to Michael Kerrisk (man-pages)

Hi Michael,

Quoted 6 lines · Michael Kerrisk (man-pages)

Hello Alex,

Quoted 1 line · Alejandro Colomar

This fixes up til trunc.3

trunc.3? I'm a little confused, since the last patch is for swab.3.

Ahh, I was also confused after your email. Now I understand it. I checked more pages after swab.3, but they didn't require changes. I wrote the last page I checked so that I wouldn't check them again in the next batch :)

Quoted 5 lines
Quoted 3 lines

(I didn't send you scanf.3
in this patch set because I did in my mom's computer and forgot to push).

:-).

Hehe

Quoted 8 lines
Quoted 4 lines

When you come back and merge all of the pending patches, I'll send/resend anything that's not in sync anyway.
So don't worry about missing some of them.

I've applied all of the below patches.

Thanks once again for all of this work!

:-)

Quoted 30 lines

Cheers,

Michael

Quoted 25 lines

Alejandro Colomar (24):
sem_getvalue.3: SYNOPSIS: Use 'restrict' in prototypes sem_wait.3: SYNOPSIS: Use 'restrict' in prototypes setaliasent.3: SYNOPSIS: Use 'restrict' in prototypes setbuf.3: SYNOPSIS: Use 'restrict' in prototypes setbuf.3: SYNOPSIS: Use 'restrict' in prototypes setnetgrent.3: SYNOPSIS: Use 'restrict' in prototypes sigwait.3: SYNOPSIS: Use 'restrict' in prototypes statvfs.3: SYNOPSIS: Use 'restrict' in prototypes stpcpy.3: SYNOPSIS: Use 'restrict' in prototypes stpncpy.3: SYNOPSIS: Use 'restrict' in prototypes strcat.3: SYNOPSIS: Use 'restrict' in prototypes strcpy.3: SYNOPSIS: Use 'restrict' in prototypes strfmon.3: SYNOPSIS: Use 'restrict' in prototypes strftime.3: SYNOPSIS: Use 'restrict' in prototypes string.3: SYNOPSIS: Use 'restrict' in prototypes string.3: SYNOPSIS: Use 'restrict' in prototypes strptime.3: SYNOPSIS: Use 'restrict' in prototypes strsep.3: SYNOPSIS: Use 'restrict' in prototypes strtod.3: SYNOPSIS: Use 'restrict' in prototypes strtoimax.3: SYNOPSIS: Use 'restrict' in prototypes strtok.3: SYNOPSIS: Use 'restrict' in prototypes strtol.3, strtoul.3: SYNOPSIS: Use 'restrict' in prototypes strxfrm.3: SYNOPSIS: Use 'restrict' in prototypes swab.3: SYNOPSIS: Use 'restrict' in prototypes

Signature · 3 lines
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/