From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76FE7A04BA; Wed, 7 Oct 2020 13:45:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D5D01B7D8; Wed, 7 Oct 2020 13:45:32 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id BD5ED1B74B for ; Wed, 7 Oct 2020 13:45:29 +0200 (CEST) IronPort-SDR: Hm6rvfDtWT3uSuC0I2wISszv35sx6ajrNuLUxDVOSGvrOhVKYDFStS24KHY7EcdAoKPEMbw2G0 Yy9V3P/J9OyQ== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="151840243" X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="151840243" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 04:45:27 -0700 IronPort-SDR: NNRccc+PHIkAI34lQK9dYrwMaam0+3xKVKVEH5sySo1KWukwY4YOV42j4bbCbrfH3UvkzWQ72L n9Ac3Tgrxlqg== X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="461293042" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.193.102]) ([10.213.193.102]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 04:45:26 -0700 To: Bruce Richardson , Olivier Matz Cc: Ciara Loftus , dev@dpdk.org References: <20201007090137.5121-1-ciara.loftus@intel.com> <20201007095131.GQ21395@platinum> <20201007102638.GB680@bricha3-MOBL.ger.corp.intel.com> <20201007102812.GC680@bricha3-MOBL.ger.corp.intel.com> From: Ferruh Yigit Message-ID: Date: Wed, 7 Oct 2020 12:45:22 +0100 MIME-Version: 1.0 In-Reply-To: <20201007102812.GC680@bricha3-MOBL.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/af_xdp: use snprintf instead of strncpy 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 10/7/2020 11:28 AM, Bruce Richardson wrote: > On Wed, Oct 07, 2020 at 11:26:38AM +0100, Bruce Richardson wrote: >> On Wed, Oct 07, 2020 at 11:51:31AM +0200, Olivier Matz wrote: >>> On Wed, Oct 07, 2020 at 10:40:32AM +0100, Ferruh Yigit wrote: >>>> On 10/7/2020 10:01 AM, Ciara Loftus wrote: >>>>> strncpy may leave the destination buffer not NULL terminated so use >>>>> snprintf instead. >>>> >>>> What do you think using 'strlcpy'? >>> >>> Or even better, rte_strscpy() >>> https://git.dpdk.org/dpdk/commit/?id=b0236c7cf761 >>> >> I think this is largely a matter of preference, and unless there is a good >> reason not to, I tend towards strlcpy as the older and more common (till >> now) interface. The main thing is just to use a function that will >> guarantee dest is null-terminated here, and both strlcpy and strscpy meet >> that criteria. >> > I'd also add that strlcpy is more likely to be recognised by tools like > coverity, compared to rte_strscpy which is DPDK-specific. > +1 to 'strlcpy'