From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH iproute2] Use libbsd for strlcpy if available Date: Mon, 29 Oct 2018 09:27:56 -0600 Message-ID: <78a4e635-1675-a92d-e7ba-ffc4a642b901@gmail.com> References: <20181029104650.24924-1-bluca@debian.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: stephen@networkplumber.org To: Luca Boccassi , netdev@vger.kernel.org Return-path: Received: from mail-pf1-f193.google.com ([209.85.210.193]:44689 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbeJ3ARF (ORCPT ); Mon, 29 Oct 2018 20:17:05 -0400 Received: by mail-pf1-f193.google.com with SMTP id j13-v6so690836pff.11 for ; Mon, 29 Oct 2018 08:27:59 -0700 (PDT) In-Reply-To: <20181029104650.24924-1-bluca@debian.org> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/29/18 4:46 AM, Luca Boccassi wrote: > If libc does not provide strlcpy check for libbsd with pkg-config to > avoid relying on inline version. > > Signed-off-by: Luca Boccassi > --- > This allows distro maintainers to be able to choose to reduce > duplication and let this code be maintained in one place, in the > external library. > > configure | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/configure b/configure > index 744d6282..1dd9ce84 100755 > --- a/configure > +++ b/configure > @@ -330,8 +330,16 @@ EOF > then > echo "no" > else > - echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG > - echo "yes" > + if ${PKG_CONFIG} libbsd --exists > + then > + echo 'CFLAGS += -include' `${PKG_CONFIG} libbsd --variable=includedir`'/bsd/string.h' \ > + `${PKG_CONFIG} libbsd --cflags` >>$CONFIG > + echo 'LDLIBS +=' `${PKG_CONFIG} libbsd --libs` >> $CONFIG > + echo "no" > + else > + echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG > + echo "yes" > + fi > fi > rm -f $TMPDIR/strtest.c $TMPDIR/strtest > } > How long has libbsd had an implementation of strlcpy? Would be safer to have a compile test to verify libbsd has it.