Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Nov 2020 13:48:58 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Scott Long <scottl@samsco.org>
Cc:        Jessica Clarke <jrtc27@freebsd.org>, Scott Long <scottl@freebsd.org>,  src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>,  svn-src-head <svn-src-head@freebsd.org>, Stefan Esser <se@freebsd.org>
Subject:   Re: svn commit: r367701 - head/lib/libutil
Message-ID:  <CANCZdfqUbooeDkJRjZY%2BF1nggRYe4zfGK1JucNUMXfw1sCuFHg@mail.gmail.com>
In-Reply-To: <9578C457-F9C9-4B27-ACCE-1B66256B06A9@samsco.org>
References:  <202011150748.0AF7mqW3016900@repo.freebsd.org> <D5492BB4-A282-4E35-B02F-1216769FDA51@freebsd.org> <A39C12CC-D3D6-4166-9089-7466FA1C2B2D@samsco.org> <CANCZdfqjpVo2q=dzKU3ox=Oaeo=s8vOSF%2BWtaK5HhYpeyrBM5Q@mail.gmail.com> <9578C457-F9C9-4B27-ACCE-1B66256B06A9@samsco.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Nov 15, 2020 at 1:13 PM Scott Long <scottl@samsco.org> wrote:

>
> > On Nov 15, 2020, at 1:05 PM, Warner Losh <imp@bsdimp.com> wrote:
> >
> > Hey Scott,
> >
> > On Sun, Nov 15, 2020 at 11:46 AM Scott Long <scottl@samsco.org> wrote:
> > The man page for strlcpy() made reference to the return value being
> > equivalent to what snprintf() does.  The man page for snprintf() states
> > that negatve return values are possible, so I assumed the same was
> > true for strlcpy().  However, now that I=E2=80=99ve looked at the imple=
mentation
> > of strlcpy(), I see that you=E2=80=99re correct.  The man pages are def=
initely
> > confusing, and this isn=E2=80=99t the only place where I think there=E2=
=80=99s
> > inconsistency in the documentation, or at least poor wording choices.
> >
> > Yea, it says both that it will never return a negative value (since
> size_t is never negative) and that it returns the same things as snprintf
> (which is true... except for that detail which it glosses over in return
> type differences).
> >
> > So this issue doesn't get lost, I've added a clarification to the
> examples in  https://reviews.freebsd.org/D27228 . Please take a look and
> let me know what you think. If more extensive edits are needed, there's
> full context so you can at least flag those in the review as well. I've
> read these too many times to see the other places you're talking about, s=
o
> a fresh set of eyes would be helpful.
> >
>
> The wording on whether or not strlcpy and strlcat will provide NULL
> termination is also inconsistent, hence my comments about it last weekend=
.
> I=E2=80=99m going to revert all of this back to and including r367075, si=
nce Stefan
> wants to do this a totally different way.  Sorry for the noise everyone a=
nd
> thanks for the help, I learned a lot through this process.
>

OK.  I'll update the man page to document the guaranteed behavior wrt NUL
as well. I know what it's trying to say, but you are not the first person
to stumble on these details. Thanks for pointing me at the ones that need
improvement. And thanks for getting the localbase issue seen through.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfqUbooeDkJRjZY%2BF1nggRYe4zfGK1JucNUMXfw1sCuFHg>