man3: SYNOPSIS: Use 'restrict' in prototypes
cover man3: SYNOPSIS: Use 'restrict' in prototypes
Hello Michael,
This fixes the remaining pages. With this, all pages have been fixed to use 'restrict'.
Kind regards,
Alex
Alejandro Colomar (17):
scanf.3: SYNOPSIS: Use 'restrict' in prototypes; ffix too. tsearch.3: SYNOPSIS: Use 'restrict' in prototypes unlocked_stdio.3: SYNOPSIS: Use 'restrict' in prototypes wcpcpy.3: SYNOPSIS: Use 'restrict' in prototypes wcpncpy.3: SYNOPSIS: Use 'restrict' in prototypes wcrtomb.3: SYNOPSIS: Use 'restrict' in prototypes wcscat.3: SYNOPSIS: Use 'restrict' in prototypes wcscpy.3: SYNOPSIS: Use 'restrict' in prototypes wcsncat.3: SYNOPSIS: Use 'restrict' in prototypes wcsncpy.3: SYNOPSIS: Use 'restrict' in prototypes wcsnrtombs.3: SYNOPSIS: Use 'restrict' in prototypes wcsrtombs.3: SYNOPSIS: Use 'restrict' in prototypes wcstoimax.3: SYNOPSIS: Use 'restrict' in prototypes wcstok.3: SYNOPSIS: Use 'restrict' in prototypes wcstombs.3: SYNOPSIS: Use 'restrict' in prototypes wmemcpy.3: SYNOPSIS: Use 'restrict' in prototypes wordexp.3: SYNOPSIS: Use 'restrict' in prototypes
man3/scanf.3 | 16 ++++++++++------ man3/tsearch.3 | 4 ++-- man3/unlocked_stdio.3 | 20 ++++++++++++-------- man3/wcpcpy.3 | 3 ++- man3/wcpncpy.3 | 4 +++- man3/wcrtomb.3 | 3 ++- man3/wcscat.3 | 3 ++- man3/wcscpy.3 | 3 ++- man3/wcsncat.3 | 4 +++- man3/wcsncpy.3 | 4 +++- man3/wcsnrtombs.3 | 5 +++-- man3/wcsrtombs.3 | 4 ++-- man3/wcstoimax.3 | 8 ++++---- man3/wcstok.3 | 5 +++-- man3/wcstombs.3 | 3 ++- man3/wmemcpy.3 | 4 +++- man3/wordexp.3 | 3 ++- 17 files changed, 60 insertions(+), 36 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/17 scanf.3: SYNOPSIS: Use 'restrict' in prototypes; ffix too.
Both POSIX and glibc use 'restrict' in scanf(), fscanf(), sscanf(), vscanf(), vfscanf(), vsscanf(). Let's use it here too.
.../glibc$ grep_glibc_prototype scanf libio/stdio.h:397:
extern int scanf (const char *__restrict __format, ...) __wur; .../glibc$ grep_glibc_prototype fscanf libio/stdio.h:391:
extern int fscanf (FILE *__restrict __stream,
const char *__restrict __format, ...) __wur;
.../glibc$ grep_glibc_prototype sscanf
libio/stdio.h:399:
extern int sscanf (const char *__restrict __s,
const char *__restrict __format, ...) __THROW;
.../glibc$ grep_glibc_prototype vscanf
libio/stdio.h:443:
extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
.../glibc$ grep_glibc_prototype vfscanf
libio/stdio.h:435:
extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
__gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
.../glibc$ grep_glibc_prototype vsscanf
libio/stdio.h:447:
extern int vsscanf (const char *__restrict __s,
const char *__restrict __format, __gnuc_va_list __arg)
__THROW __attribute__ ((__format__ (__scanf__, 2, 0)));.../glibc$
Also reorder v* functions to match the order of non-v functions.
--- man3/scanf.3 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
man3/scanf.3 +10 -6
@@ -56,15 +56,19 @@ scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion .nf .B #include <stdio.h> .PP -.BI "int scanf(const char *" format ", ...);" -.BI "int fscanf(FILE *" stream ", const char *" format ", ...);" -.BI "int sscanf(const char *" str ", const char *" format ", ...);" +.BI "int scanf(const char *restrict " format ", ...);" +.BI "int fscanf(FILE *restrict " stream , +.BI " const char *restrict " format ", ...);" +.BI "int sscanf(const char *restrict " str , +.BI " const char *restrict " format ", ...);" .PP .B #include <stdarg.h> .PP -.BI "int vscanf(const char *" format ", va_list " ap ); -.BI "int vsscanf(const char *" str ", const char *" format ", va_list " ap ); -.BI "int vfscanf(FILE *" stream ", const char *" format ", va_list " ap ); +.BI "int vscanf(const char *restrict " format ", va_list " ap ); +.BI "int vfscanf(FILE *restrict " stream , +.BI " const char *restrict " format ", va_list " ap ); +.BI "int vsscanf(const char *restrict " str , +.BI " const char *restrict " format ", va_list " ap ); .fi .PP .RS -4
Signature · 1 line
2.30.1
PATCH 2/17 tsearch.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in tdelete().
Let's use it here too.
.../glibc$ grep_glibc_prototype tdelete misc/search.h:138:
extern void *tdelete (const void *__restrict __key,
void **__restrict __rootp, __compar_fn_t __compar);
.../glibc$
--- man3/tsearch.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man3/tsearch.3 +2 -2
@@ -35,11 +35,11 @@ tsearch, tfind, tdelete, twalk, tdestroy \- manage a binary search tree .BI " int (*" compar ")(const void *, const void *));" .BI "void *tfind(const void *" key ", void *const *" rootp , .BI " int (*" compar ")(const void *, const void *));" -.BI "void *tdelete(const void *" key ", void **" rootp , +.BI "void *tdelete(const void *restrict " key ", void **restrict " rootp , .BI " int (*" compar ")(const void *, const void *));" .BI "void twalk(const void *" root , .BI " void (*" action ")(const void *" nodep ", VISIT " which , -.BI " int " depth "));" +.BI " int " depth )); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .B #include <search.h>
Signature · 1 line
2.30.1
PATCH 3/17 unlocked_stdio.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro Colomarglibc uses 'restrict' in fread_unlocked(), fwrite_unlocked(), fgets_unlocked(), fputs_unlocked(), fgetws_unlocked(), fputws_unlocked(). Let's use it here too.
.../glibc$ grep_glibc_prototype fread_unlocked libio/stdio.h:678:
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) __wur;
.../glibc$ grep_glibc_prototype fwrite_unlocked
libio/stdio.h:680:
extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream);
.../glibc$ grep_glibc_prototype fgets_unlocked
libio/stdio.h:591:
extern char *fgets_unlocked (char *__restrict __s, int __n,
FILE *__restrict __stream) __wur
__attr_access ((__write_only__, 1, 2));
.../glibc$ grep_glibc_prototype fputs_unlocked
libio/stdio.h:667:
extern int fputs_unlocked (const char *__restrict __s,
FILE *__restrict __stream);
.../glibc$ grep_glibc_prototype fgetws_unlocked
wcsmbs/wchar.h:820:
extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
__FILE *__restrict __stream);
.../glibc$ grep_glibc_prototype fputws_unlocked
wcsmbs/wchar.h:829:
extern int fputws_unlocked (const wchar_t *__restrict __ws,
__FILE *__restrict __stream);.../glibc$
--- man3/unlocked_stdio.3 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
man3/unlocked_stdio.3 +12 -8
@@ -44,13 +44,15 @@ putchar_unlocked \- nonlocking stdio functions .BI "int fgetc_unlocked(FILE *" stream ); .BI "int fputc_unlocked(int " c ", FILE *" stream ); .PP -.BI "size_t fread_unlocked(void *" ptr ", size_t " size ", size_t " n , -.BI " FILE *" stream ); -.BI "size_t fwrite_unlocked(const void *" ptr ", size_t " size ", size_t " n , -.BI " FILE *" stream ); +.BI "size_t fread_unlocked(void *restrict " ptr ", size_t " size ", size_t " n , +.BI " FILE *restrict " stream ); +.BI "size_t fwrite_unlocked(const void *restrict " ptr ", size_t " size \ +", size_t " n , +.BI " FILE *restrict " stream ); .PP -.BI "char *fgets_unlocked(char *" s ", int " n ", FILE *" stream ); -.BI "int fputs_unlocked(const char *" s ", FILE *" stream ); +.BI "char *fgets_unlocked(char *restrict " s ", int " n \ +", FILE *restrict " stream ); +.BI "int fputs_unlocked(const char *restrict " s ", FILE *restrict " stream ); .PP .B #include <wchar.h> .PP
@@ -62,8 +64,10 @@ putchar_unlocked \- nonlocking stdio functions .BI "wint_t putwc_unlocked(wchar_t " wc ", FILE *" stream ); .BI "wint_t putwchar_unlocked(wchar_t " wc ); .PP -.BI "wchar_t *fgetws_unlocked(wchar_t *" ws ", int " n ", FILE *" stream ); -.BI "int fputws_unlocked(const wchar_t *" ws ", FILE *" stream ); +.BI "wchar_t *fgetws_unlocked(wchar_t *restrict " ws ", int " n , +.BI " FILE *restrict " stream ); +.BI "int fputws_unlocked(const wchar_t *restrict " ws , +.BI " FILE *restrict " stream ); .fi .PP .RS -4
Signature · 1 line
2.30.1
PATCH 4/17 wcpcpy.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcpcpy().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcpcpy wcsmbs/wchar.h:551:
extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
const wchar_t *__restrict __src) __THROW;
.../glibc$
--- man3/wcpcpy.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man3/wcpcpy.3 +2 -1
@@ -19,7 +19,8 @@ wcpcpy \- copy a wide-character string, returning a pointer to its end .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcpcpy(wchar_t *" dest ", const wchar_t *" src ); +.BI "wchar_t *wcpcpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src ); .fi .PP .RS -4
Signature · 1 line
2.30.1
PATCH 5/17 wcpncpy.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcpncpy().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcpncpy wcsmbs/wchar.h:556:
extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
const wchar_t *__restrict __src, size_t __n)
__THROW;.../glibc$
--- man3/wcpncpy.3 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
man3/wcpncpy.3 +3 -1
@@ -20,7 +20,9 @@ returning a pointer to its end .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcpncpy(wchar_t *" dest ", const wchar_t *" src ", size_t " n ); +.BI "wchar_t *wcpncpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.BI " size_t " n ); .fi .PP .RS -4
Signature · 1 line
2.30.1
PATCH 6/17 wcrtomb.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcrtomb().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcrtomb wcsmbs/wchar.h:301:
extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
mbstate_t *__restrict __ps) __THROW;
.../glibc$
--- man3/wcrtomb.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man3/wcrtomb.3 +2 -1
@@ -20,7 +20,8 @@ wcrtomb \- convert a wide character to a multibyte sequence .nf .B #include <wchar.h> .PP -.BI "size_t wcrtomb(char *" s ", wchar_t " wc ", mbstate_t *" ps ); +.BI "size_t wcrtomb(char *restrict " s ", wchar_t " wc \ +", mbstate_t *restrict " ps ); .fi .SH DESCRIPTION The main case for this function is when
Signature · 1 line
2.30.1
PATCH 7/17 wcscat.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcscat().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcscat wcsmbs/wchar.h:97:
extern wchar_t *wcscat (wchar_t *__restrict __dest,
const wchar_t *__restrict __src)
__THROW __nonnull ((1, 2));.../glibc$
--- man3/wcscat.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man3/wcscat.3 +2 -1
@@ -20,7 +20,8 @@ wcscat \- concatenate two wide-character strings .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcscat(wchar_t *" dest ", const wchar_t *" src ); +.BI "wchar_t *wcscat(wchar_t *restrict " dest \ +", const wchar_t *restrict " src ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.1
PATCH 8/17 wcscpy.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcscpy().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcscpy wcsmbs/wchar.h:87:
extern wchar_t *wcscpy (wchar_t *__restrict __dest,
const wchar_t *__restrict __src)
__THROW __nonnull ((1, 2));.../glibc$
--- man3/wcscpy.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man3/wcscpy.3 +2 -1
@@ -20,7 +20,8 @@ wcscpy \- copy a wide-character string .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcscpy(wchar_t *" dest ", const wchar_t *" src ); +.BI "wchar_t *wcscpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.1
PATCH 9/17 wcsncat.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcsncat().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcsncat wcsmbs/wchar.h:101:
extern wchar_t *wcsncat (wchar_t *__restrict __dest,
const wchar_t *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));.../glibc$
--- man3/wcsncat.3 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
man3/wcsncat.3 +3 -1
@@ -20,7 +20,9 @@ wcsncat \- concatenate two wide-character strings .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcsncat(wchar_t *" dest ", const wchar_t *" src ", size_t " n ); +.BI "wchar_t *wcsncat(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.BI " size_t " n ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.1
PATCH 10/17 wcsncpy.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcsncpy().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcsncpy wcsmbs/wchar.h:92:
extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
const wchar_t *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));.../glibc$
--- man3/wcsncpy.3 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
man3/wcsncpy.3 +3 -1
@@ -20,7 +20,9 @@ wcsncpy \- copy a fixed-size string of wide characters .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcsncpy(wchar_t *" dest ", const wchar_t *" src ", size_t " n ); +.BI "wchar_t *wcsncpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.BI " size_t " n ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.1
PATCH 11/17 wcsnrtombs.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcsnrtombs(). Let's use it here too.
.../glibc$ grep_glibc_prototype wcsnrtombswcsmbs/wchar.h:357:
extern size_t wcsnrtombs (char *__restrict __dst,
const wchar_t **__restrict __src, size_t __nwc, size_t __len, mbstate_t *__restrict __ps) __THROW;
.../glibc$
--- man3/wcsnrtombs.3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
man3/wcsnrtombs.3 +3 -2
@@ -19,8 +19,9 @@ wcsnrtombs \- convert a wide-character string to a multibyte string .nf .B #include <wchar.h> .PP -.BI "size_t wcsnrtombs(char *" dest ", const wchar_t **" src ", size_t " nwc , -.BI " size_t " len ", mbstate_t *" ps ); +.BI "size_t wcsnrtombs(char *restrict " dest ", const wchar_t **restrict " src , +.BI " size_t " nwc ", size_t " len \ +", mbstate_t *restrict " ps ); .fi .PP .RS -4
Signature · 1 line
2.30.1
PATCH 12/17 wcsrtombs.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcsrtombs(). Let's use it here too.
.../glibc$ grep_glibc_prototype wcsrtombswcsmbs/wchar.h:343:
extern size_t wcsrtombs (char *__restrict __dst,
const wchar_t **__restrict __src, size_t __len, mbstate_t *__restrict __ps) __THROW;
.../glibc$
--- man3/wcsrtombs.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man3/wcsrtombs.3 +2 -2
@@ -20,8 +20,8 @@ wcsrtombs \- convert a wide-character string to a multibyte string .nf .B #include <wchar.h> .PP -.BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src , -.BI " size_t " len ", mbstate_t *" ps ); +.BI "size_t wcsrtombs(char *restrict " dest ", const wchar_t **restrict " src , +.BI " size_t " len ", mbstate_t *restrict " ps ); .fi .SH DESCRIPTION If
Signature · 1 line
2.30.1
PATCH 13/17 wcstoimax.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcstoimax(), wcstoumax(). Let's use it here too.
.../glibc$ grep_glibc_prototype wcstoimax stdlib/inttypes.h:305:
extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
__gwchar_t **__restrict __endptr, int __base)
__THROW;
.../glibc$ grep_glibc_prototype wcstoumax
stdlib/inttypes.h:310:
extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
__gwchar_t ** __restrict __endptr, int __base)
__THROW;.../glibc$
--- man3/wcstoimax.3 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
man3/wcstoimax.3 +4 -4
@@ -29,10 +29,10 @@ wcstoimax, wcstoumax \- convert wide-character string to integer .B #include <stddef.h> .B #include <inttypes.h> .PP -.BI "intmax_t wcstoimax(const wchar_t *" nptr ", wchar_t **" endptr \ -", int " base ); -.BI "uintmax_t wcstoumax(const wchar_t *" nptr ", wchar_t **" endptr \ -", int " base ); +.BI "intmax_t wcstoimax(const wchar_t *restrict " nptr , +.BI " wchar_t **restrict " endptr ", int " base ); +.BI "uintmax_t wcstoumax(const wchar_t *restrict " nptr , +.BI " wchar_t **restrict " endptr ", int " base ); .fi .SH DESCRIPTION These functions are just like
Signature · 1 line
2.30.1
PATCH 14/17 wcstok.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcstok().
Let's use it here too.
.../glibc$ grep_glibc_prototype wcstokwcsmbs/wchar.h:217:
extern wchar_t *wcstok (wchar_t *__restrict __s,
const wchar_t *__restrict __delim, wchar_t **__restrict __ptr) __THROW;
.../glibc$
--- man3/wcstok.3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
man3/wcstok.3 +3 -2
@@ -20,8 +20,9 @@ wcstok \- split wide-character string into tokens .nf .B #include <wchar.h> .PP -.BI "wchar_t *wcstok(wchar_t *" wcs ", const wchar_t *" delim \ -", wchar_t **" ptr ); +.BI "wchar_t *wcstok(wchar_t *restrict " wcs \ +", const wchar_t *restrict " delim , +.BI " wchar_t **restrict " ptr ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.1
PATCH 15/17 wcstombs.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wcstombs(). Let's use it here too.
.../glibc$ grep_glibc_prototype wcstombsstdlib/stdlib.h:937:
extern size_t wcstombs (char *__restrict __s,
const wchar_t *__restrict __pwcs, size_t __n)
__THROW __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
.../glibc$
--- man3/wcstombs.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man3/wcstombs.3 +2 -1
@@ -20,7 +20,8 @@ wcstombs \- convert a wide-character string to a multibyte string .nf .B #include <stdlib.h> .PP -.BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n ); +.BI "size_t wcstombs(char *restrict " dest ", const wchar_t *restrict " src , +.BI " size_t " n ); .fi .SH DESCRIPTION If
Signature · 1 line
2.30.1
PATCH 16/17 wmemcpy.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wmemcpy().
Let's use it here too.
.../glibc$ grep_glibc_prototype wmemcpy wcsmbs/wchar.h:262:
extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
const wchar_t *__restrict __s2, size_t __n) __THROW;
.../glibc$
--- man3/wmemcpy.3 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
man3/wmemcpy.3 +3 -1
@@ -20,7 +20,9 @@ wmemcpy \- copy an array of wide-characters .nf .B #include <wchar.h> .PP -.BI "wchar_t *wmemcpy(wchar_t *" dest ", const wchar_t *" src ", size_t " n ); +.BI "wchar_t *wmemcpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.BI " size_t " n ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.1
PATCH 17/17 wordexp.3: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarBoth POSIX and glibc use 'restrict' in wordexp().
Let's use it here too.
.../glibc$ grep_glibc_prototype wordexp posix/wordexp.h:62:
extern int wordexp (const char *__restrict __words,
wordexp_t *__restrict __pwordexp, int __flags);
.../glibc$
--- man3/wordexp.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man3/wordexp.3 +2 -1
@@ -28,7 +28,8 @@ wordexp, wordfree \- perform word expansion like a posix-shell .nf .B "#include <wordexp.h>" .PP -.BI "int wordexp(const char *" s ", wordexp_t *" p ", int " flags ); +.BI "int wordexp(const char *restrict " s ", wordexp_t *restrict " p \ +", int " flags ); .BI "void wordfree(wordexp_t *" p ); .fi .PP
Signature · 1 line
2.30.1
Hi,
Quoted 2 lines · Alejandro Colomar
This fixes the remaining pages. With this, all pages have been fixed to use 'restrict'.
Probably the context for this came earlier, but I didn't see it in the commit message, I figure I should ask:
What is the benefit of getting this right for a human reader? Does knowing which pointer arguments can't alias help them in tracking down some bugs, for example? Or is it going to help them in some other way?
Thanks,
Jonathan
Hi Jonathan,
Quoted 9 lines · Jonathan Nieder
Hi,
Quoted 2 lines · Alejandro Colomar
This fixes the remaining pages. With this, all pages have been fixed to use 'restrict'.
Probably the context for this came earlier, but I didn't see it in the commit message, I figure I should ask:
The origin is here:
<https://lore.kernel.org/linux-man/[email protected]/T/>
And a later (short) discussion about it is here:
<https://lore.kernel.org/linux-man/[email protected]/T/>
Quoted 5 lines
What is the benefit of getting this right for a human reader? Does knowing which pointer arguments can't alias help them in tracking down some bugs, for example? Or is it going to help them in some other way?
Yes, I think it will help fixing bugs, or more likely preventing them.
Think for example the case of memcpy(3) (by that time 'restrict' didn't exist), where people would incorrectly use it as if it were memmove(3) ignoring that it could be dangerous (see the NOTES section in memcpy(3)).
Cheers,
Alex
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/
Hello Alex,
Quoted 3 lines · Alejandro Colomar
Hello Michael,
This fixes the remaining pages. With this, all pages have been fixed to use 'restrict'.
Thank you!! Patches applied.
Cheers,
Michael
Quoted 38 lines
Alejandro Colomar (17):
scanf.3: SYNOPSIS: Use 'restrict' in prototypes; ffix too. tsearch.3: SYNOPSIS: Use 'restrict' in prototypes unlocked_stdio.3: SYNOPSIS: Use 'restrict' in prototypes wcpcpy.3: SYNOPSIS: Use 'restrict' in prototypes wcpncpy.3: SYNOPSIS: Use 'restrict' in prototypes wcrtomb.3: SYNOPSIS: Use 'restrict' in prototypes wcscat.3: SYNOPSIS: Use 'restrict' in prototypes wcscpy.3: SYNOPSIS: Use 'restrict' in prototypes wcsncat.3: SYNOPSIS: Use 'restrict' in prototypes wcsncpy.3: SYNOPSIS: Use 'restrict' in prototypes wcsnrtombs.3: SYNOPSIS: Use 'restrict' in prototypes wcsrtombs.3: SYNOPSIS: Use 'restrict' in prototypes wcstoimax.3: SYNOPSIS: Use 'restrict' in prototypes wcstok.3: SYNOPSIS: Use 'restrict' in prototypes wcstombs.3: SYNOPSIS: Use 'restrict' in prototypes wmemcpy.3: SYNOPSIS: Use 'restrict' in prototypes wordexp.3: SYNOPSIS: Use 'restrict' in prototypesman3/scanf.3 | 16 ++++++++++------ man3/tsearch.3 | 4 ++-- man3/unlocked_stdio.3 | 20 ++++++++++++-------- man3/wcpcpy.3 | 3 ++- man3/wcpncpy.3 | 4 +++- man3/wcrtomb.3 | 3 ++- man3/wcscat.3 | 3 ++- man3/wcscpy.3 | 3 ++- man3/wcsncat.3 | 4 +++- man3/wcsncpy.3 | 4 +++- man3/wcsnrtombs.3 | 5 +++-- man3/wcsrtombs.3 | 4 ++-- man3/wcstoimax.3 | 8 ++++---- man3/wcstok.3 | 5 +++-- man3/wcstombs.3 | 3 ++- man3/wmemcpy.3 | 4 +++- man3/wordexp.3 | 3 ++- 17 files changed, 60 insertions(+), 36 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/