Bug 212724 - function signatures in man page missing the "restrict" keyword
Summary: function signatures in man page missing the "restrict" keyword
Status: Open
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-09-16 09:30 UTC by Ori Avtalion
Modified: 2021-10-12 05:22 UTC (History)
2 users (show)

See Also:


Attachments
patch to memccpy(3), memcpy(3), and strtok(3) (1.32 KB, patch)
2021-10-12 05:19 UTC, Felix Johnson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ori Avtalion 2016-09-16 09:30:08 UTC
When a function has the "restrict" keyword, it is usually mentioned in the manpage.

Some man pages omit it. For example, strtok:

strok has the signature [1]:

  char *strtok(char * __restrict, const char * __restrict);

The manpage lists it as [2]:
  char * strtok(char *str, const char *sep);

It should be:
  char * strtok(char * restrict str, const char * restrict sep);

[1] https://github.com/freebsd/freebsd/blob/b8aaa2c367f1038f28506521674b9b40b8a51352/include/string.h#L119
[2] https://github.com/freebsd/freebsd/blob/b8aaa2c367f1038f28506521674b9b40b8a51352/lib/libc/string/strtok.3#L58


A few other functions in string.h that use "restrict", but omit it in their man pages:
* memccpy
* memcpy
* stpcpy
* stpncpy
* strlcat
* strncat
* strncpy

memcpy is interesting: Its documentation says it uses bcopy, and therefore the strings may overlap. However, the signature in string.h includes the "restrict" keywords.
Comment 1 Felix Johnson freebsd_triage 2021-10-12 05:19:06 UTC
Created attachment 228613 [details]
patch to memccpy(3), memcpy(3), and strtok(3)

Modify function signatures for memccpy, memcpy, mempcpy, and strtok to include the restrict keyword.
Comment 2 Felix Johnson freebsd_triage 2021-10-12 05:22:00 UTC
The functions in strcpy(3) already have the restrict keyword.
This includes stpcpy, stpncpy, strcpy, and strncpy.
The functions in strlcpy(3) (strlcpy, strlcat) have the restrict keyword.