From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 0B4DAA0679 for ; Wed, 3 Apr 2019 17:56:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D75031B4C0; Wed, 3 Apr 2019 17:56:44 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 3D10A1B4B6 for ; Wed, 3 Apr 2019 17:56:43 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 08:56:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="146293060" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.7.174]) by FMSMGA003.fm.intel.com with SMTP; 03 Apr 2019 08:56:40 -0700 Received: by (sSMTP sendmail emulation); Wed, 03 Apr 2019 16:56:39 +0100 Date: Wed, 3 Apr 2019 16:56:39 +0100 From: Bruce Richardson To: Stephen Hemminger Cc: dev@dpdk.org Message-ID: <20190403155638.GA1336@bricha3-MOBL.ger.corp.intel.com> References: <20190403144505.46234-1-bruce.richardson@intel.com> <20190403144505.46234-5-bruce.richardson@intel.com> <20190403085132.1fa33194@shemminger-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline In-Reply-To: <20190403085132.1fa33194@shemminger-XPS-13-9360> User-Agent: Mutt/1.11.4 (2019-03-13) Subject: Re: [dpdk-dev] [PATCH 4/5] replace snprintf with strlcpy without adding extra include 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" Message-ID: <20190403155639.HUj3Tn7TX7dhzkzHJEZysPxRbasHtIiFIlkyjhCXSgI@z> On Wed, Apr 03, 2019 at 08:51:32AM -0700, Stephen Hemminger wrote: > On Wed, 3 Apr 2019 15:45:04 +0100 > Bruce Richardson wrote: > > > diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c > > index d215acecc..a542f6f5d 100644 > > --- a/lib/librte_ring/rte_ring.c > > +++ b/lib/librte_ring/rte_ring.c > > @@ -78,7 +78,7 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count, > > > > /* init the ring structure */ > > memset(r, 0, sizeof(*r)); > > - ret = snprintf(r->name, sizeof(r->name), "%s", name); > > + ret = strlcpy(r->name, name, sizeof(r->name)); > > if (ret < 0 || ret >= (int)sizeof(r->name)) > > I would rather use the name length that is part of the header file. > > if (strnlen(name, RTE_RING_NAMESIZE) == RTE_RING_NAMESIZE) > return -ENAMETOOLONG; > > strlcpy(r->name, name, sizeof(r->name)) > Yes, though honestly it's a matter of preference. Since this was a scripted replacement each change wasn't checked in too much detail other than a cursory check for correctness.