From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7C3C97CBB; Tue, 8 May 2018 21:53:20 +0200 (CEST) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2018 12:53:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,379,1520924400"; d="scan'208";a="44262640" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.7.111]) by fmsmga002.fm.intel.com with SMTP; 08 May 2018 12:53:17 -0700 Received: by (sSMTP sendmail emulation); Tue, 08 May 2018 20:53:16 +0100 Date: Tue, 8 May 2018 20:53:15 +0100 From: Bruce Richardson To: dev-bounces@dpdk.org Cc: Andy Green , "dev@dpdk.org" Message-ID: <20180508195315.GB18108@bricha3-MOBL.ger.corp.intel.com> References: <152575364588.56689.3300796065057551728.stgit@localhost.localdomain> <152575381332.56689.17827274556476490336.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 09/18] drivers: net: qede: fix strncpy constant and NUL 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: Tue, 08 May 2018 19:53:21 -0000 On Tue, May 08, 2018 at 05:59:47PM +0000, dev-bounces@dpdk.org wrote: > > > > -----Original Message----- > > From: dev On Behalf Of Andy Green > > Sent: Monday, May 7, 2018 11:30 PM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH 09/18] drivers: net: qede: fix strncpy constant and > > NUL > > > > > > --- > > drivers/net/qede/base/ecore_int.c | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/net/qede/base/ecore_int.c > > b/drivers/net/qede/base/ecore_int.c > > index f43781ba4..c809d84ef 100644 > > --- a/drivers/net/qede/base/ecore_int.c > > +++ b/drivers/net/qede/base/ecore_int.c > > @@ -1103,10 +1103,12 @@ static enum _ecore_status_t > > ecore_int_deassertion(struct ecore_hwfn *p_hwfn, > > OSAL_SNPRINTF(bit_name, 30, > > p_aeu->bit_name, > > num); > > - else > > - OSAL_STRNCPY(bit_name, > > - p_aeu->bit_name, > > - 30); > > + else { > > + strncpy(bit_name, > > + p_aeu->bit_name, > > + sizeof(bit_name) - 1); > > + bit_name[sizeof(bit_name) - 1] > > = '\0'; > > + } > > I think you can retain OSAL_STRNCPY and just replace 30 with 'bit_name[sizeof(bit_name) - 1' and then set last byte with '\0' just like you did. Can that actually be fixed inside OSAL_STRNCPY itself, rather than having each use needing to explicitly null-terminate?