Re: Correct name for size_t argument in strlcpy.3
On Fri, 30 Apr 2021 11:15:21 -0600, "Theo de Raadt" wrote: > I disagree. > > "dstsize" is conceptually easier for readers to understand. > > Secondly, there is nothing which says the library code has to match the > manual page. Implementation does not need to match documentation. My feelings exactly. - todd
Re: Correct name for size_t argument in strlcpy.3
I disagree. "dstsize" is conceptually easier for readers to understand. Secondly, there is nothing which says the library code has to match the manual page. Implementation does not need to match documentation. Emil Engler wrote: > Hello tech@, > currently the man-page for strlcpy(3) and strlcat(3) calls > the third argument for those functions "dstsize" whereas the > C source code calls it "dsize". This patch addresses this issue > by renaming it to "dsize" to keep coherency between the man-page > and the source code. > > diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3 > index a14145e199f..7e0a6379638 100644 > --- a/lib/libc/string/strlcpy.3 > +++ b/lib/libc/string/strlcpy.3 > @@ -14,7 +14,7 @@ > .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > .\" > -.Dd $Mdocdate: January 25 2019 $ > +.Dd $Mdocdate: April 30 2021 $ > .Dt STRLCPY 3 > .Os > .Sh NAME > @@ -24,9 +24,9 @@ > .Sh SYNOPSIS > .In string.h > .Ft size_t > -.Fn strlcpy "char *dst" "const char *src" "size_t dstsize" > +.Fn strlcpy "char *dst" "const char *src" "size_t dsize" > .Ft size_t > -.Fn strlcat "char *dst" "const char *src" "size_t dstsize" > +.Fn strlcat "char *dst" "const char *src" "size_t dsize" > .Sh DESCRIPTION > The > .Fn strlcpy > @@ -47,17 +47,17 @@ and > take the full size of the destination buffer and guarantee > NUL-termination if there is room. > Note that room for the NUL should be included in > -.Fa dstsize . > +.Fa dsize . > .Pp > .Fn strlcpy > copies up to > -.Fa dstsize > +.Fa dsize > \- 1 characters from the string > .Fa src > to > .Fa dst , > NUL-terminating the result if > -.Fa dstsize > +.Fa dsize > is not 0. > .Pp > .Fn strlcat > @@ -66,17 +66,17 @@ appends string > to the end of > .Fa dst . > It will append at most > -.Fa dstsize > +.Fa dsize > \- strlen(dst) \- 1 characters. > It will then NUL-terminate, unless > -.Fa dstsize > +.Fa dsize > is 0 or the original > .Fa dst > string was longer than > -.Fa dstsize > +.Fa dsize > (in practice this should not happen > as it means that either > -.Fa dstsize > +.Fa dsize > is incorrect or that > .Fa dst > is not a proper string). > @@ -121,7 +121,7 @@ the length of > .Pp > If the return value is > .Cm >= > -.Va dstsize , > +.Va dsize , > the output string has been truncated. > It is the caller's responsibility to handle this. > .Sh EXAMPLES >
Correct name for size_t argument in strlcpy.3
Hello tech@, currently the man-page for strlcpy(3) and strlcat(3) calls the third argument for those functions "dstsize" whereas the C source code calls it "dsize". This patch addresses this issue by renaming it to "dsize" to keep coherency between the man-page and the source code. diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3 index a14145e199f..7e0a6379638 100644 --- a/lib/libc/string/strlcpy.3 +++ b/lib/libc/string/strlcpy.3 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 25 2019 $ +.Dd $Mdocdate: April 30 2021 $ .Dt STRLCPY 3 .Os .Sh NAME @@ -24,9 +24,9 @@ .Sh SYNOPSIS .In string.h .Ft size_t -.Fn strlcpy "char *dst" "const char *src" "size_t dstsize" +.Fn strlcpy "char *dst" "const char *src" "size_t dsize" .Ft size_t -.Fn strlcat "char *dst" "const char *src" "size_t dstsize" +.Fn strlcat "char *dst" "const char *src" "size_t dsize" .Sh DESCRIPTION The .Fn strlcpy @@ -47,17 +47,17 @@ and take the full size of the destination buffer and guarantee NUL-termination if there is room. Note that room for the NUL should be included in -.Fa dstsize . +.Fa dsize . .Pp .Fn strlcpy copies up to -.Fa dstsize +.Fa dsize \- 1 characters from the string .Fa src to .Fa dst , NUL-terminating the result if -.Fa dstsize +.Fa dsize is not 0. .Pp .Fn strlcat @@ -66,17 +66,17 @@ appends string to the end of .Fa dst . It will append at most -.Fa dstsize +.Fa dsize \- strlen(dst) \- 1 characters. It will then NUL-terminate, unless -.Fa dstsize +.Fa dsize is 0 or the original .Fa dst string was longer than -.Fa dstsize +.Fa dsize (in practice this should not happen as it means that either -.Fa dstsize +.Fa dsize is incorrect or that .Fa dst is not a proper string). @@ -121,7 +121,7 @@ the length of .Pp If the return value is .Cm >= -.Va dstsize , +.Va dsize , the output string has been truncated. It is the caller's responsibility to handle this. .Sh EXAMPLES