From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 83CAA23B for ; Mon, 12 Mar 2018 12:51:20 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2018 04:51:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,461,1515484800"; d="scan'208";a="24912351" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.36]) by orsmga006.jf.intel.com with SMTP; 12 Mar 2018 04:51:17 -0700 Received: by (sSMTP sendmail emulation); Mon, 12 Mar 2018 11:51:16 +0000 Date: Mon, 12 Mar 2018 11:51:16 +0000 From: Bruce Richardson To: dev@dpdk.org Cc: Stephen Hemminger Message-ID: <20180312115115.GB1704@bricha3-MOBL3.ger.corp.intel.com> References: <20180220170727.220340-1-bruce.richardson@intel.com> <20180312113300.115551-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180312113300.115551-1-bruce.richardson@intel.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.3 (2018-01-21) Subject: Re: [dpdk-dev] [PATCH 1/2] add support for strlcpy function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2018 11:51:20 -0000 On Mon, Mar 12, 2018 at 11:32:59AM +0000, Bruce Richardson wrote: > The strncpy function is error prone for doing "safe" string copies, so > we generally try to use "snprintf" instead in the code. The function > "strlcpy" is a better alternative, since it better conveys the > intention of the programmer, and doesn't suffer from the non-null > terminating behaviour of it's n'ed brethern. > > The downside of this function is that it is not available by default > on linux, though standard in the BSD's. It is available on most > distros by installing "libbsd" package. > > This patch therefore provides the following in rte_string_fns.h to ensure > that strlcpy is available there: > * for BSD, include string.h as normal > * if RTE_USE_LIBBSD is set, include > * if not set, fallback to snprintf for strlcpy > > Using make build system, the RTE_USE_LIBBSD is a hard-coded value to "n", > but when using meson, it's automatically set based on what is available > on the platform. > > Signed-off-by: Bruce Richardson > > ---- > RFC->v1: > * split patch into 2, to separate out snprintf replacement > * added missing include in mlx drivers > * adding linking support against libbsd when feature is enabled > * make strlcpy an inline function rather than macro > * fix support on BSD where strict posix compliance is requested and > therefore strlcpy is not available. > --- Forgot to include Stephen's reviewed-by from RFC: Reviewed-by: Stephen Hemminger