From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0083.outbound.protection.outlook.com [104.47.37.83]) by dpdk.org (Postfix) with ESMTP id 6D1947CCC; Tue, 8 May 2018 22:02:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dkUSi4+RLHuDlPFIoNV5/HwxNQ5RaLBpZDXjPo7EKDE=; b=KptiGhFTH2HLMtRdFhhVcmgphjFxo/J6aZEuqTqhJTsZukytcZn7+W4SfJ7rBbLqfXFLWR+33E1GXgP0XNK/JZDw14atOr3230uFyI/u5H/bLAcVxNY4MnDNsoc4Vsx25DH7kuOnnqOHnv61csMQchb1OBgvrFxeEksLLiC2TJM= Received: from DM2PR07MB1547.namprd07.prod.outlook.com (10.161.140.147) by DM2PR07MB559.namprd07.prod.outlook.com (10.141.158.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.16; Tue, 8 May 2018 20:02:27 +0000 Received: from DM2PR07MB1547.namprd07.prod.outlook.com ([fe80::d43c:136b:6bb1:d48a]) by DM2PR07MB1547.namprd07.prod.outlook.com ([fe80::d43c:136b:6bb1:d48a%16]) with mapi id 15.20.0755.012; Tue, 8 May 2018 20:02:26 +0000 From: "Shaikh, Shahed" To: Bruce Richardson , "dev-bounces@dpdk.org" CC: Andy Green , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 09/18] drivers: net: qede: fix strncpy constant and NUL Thread-Index: AQHT5opJkKjHNvmLLU6SQHfKuWuPEqQmHqJwgAAgsYCAAABt0A== Date: Tue, 8 May 2018 20:02:26 +0000 Message-ID: References: <152575364588.56689.3300796065057551728.stgit@localhost.localdomain> <152575381332.56689.17827274556476490336.stgit@localhost.localdomain> <20180508195315.GB18108@bricha3-MOBL.ger.corp.intel.com> In-Reply-To: <20180508195315.GB18108@bricha3-MOBL.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Shahed.Shaikh@cavium.com; x-originating-ip: [198.186.1.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM2PR07MB559; 7:7iZENWGwN2y2YBASCf7szYPuilzrbE7YjxqM3OsIhXDJaaO1VjxC/ab+JzMY8FgNwWtisTMWuG1kq/rSdVZ4/gW8YACuK0kWLRz69KEd8zBTT6Qed+pqpcpSkw3dtwAj62zrXStaQiXrUdXTDJ6Ppd7iGwFmXtPUhZqQKwn79eVRMEWgp6DkZCSs39kmcoOTI1e3BOvDbj3fPiKT9f5PDmG6jaEhSZrI6z/kNxSYQtU5+Injoh6GezTtOjAtLjNg x-ms-exchange-antispam-srfa-diagnostics: SOS; x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM2PR07MB559; x-ms-traffictypediagnostic: DM2PR07MB559: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089)(17755550239193); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:DM2PR07MB559; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB559; x-forefront-prvs: 0666E15D35 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39380400002)(376002)(396003)(346002)(366004)(39860400002)(189003)(199004)(13464003)(5250100002)(6246003)(55016002)(2501003)(25786009)(6116002)(3846002)(7736002)(186003)(2900100001)(9686003)(4326008)(8936002)(478600001)(81156014)(72206003)(93886005)(86362001)(97736004)(68736007)(316002)(486006)(105586002)(305945005)(53546011)(3660700001)(446003)(66066001)(229853002)(2906002)(3280700002)(7696005)(76176011)(6436002)(99286004)(476003)(6506007)(74316002)(81166006)(5660300001)(14454004)(54906003)(53936002)(102836004)(110136005)(11346002)(59450400001)(106356001)(26005)(33656002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB559; H:DM2PR07MB1547.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Gh27UsDhtaqbPpkq/EbdERSVpNJWEbvf76iTZMXyKZJhI5ZmwL1MujWEsosR3p2POaEyI0w+hxDVVmqWniiKubh0rImY0x4qKJ8hGn4uz3T6VORFi/+umYgpsxU7ZPilTFhYut2fSz7SDHKg3t54/w/sXTeF7f0Om4tXwCdEIdOu/YgGZzokqpUNXnCXojEK spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0d4b0488-8a59-47e2-418a-08d5b51e9f4b X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d4b0488-8a59-47e2-418a-08d5b51e9f4b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2018 20:02:26.7386 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB559 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 20:02:30 -0000 > -----Original Message----- > From: dev On Behalf Of Bruce Richardson > Sent: Tuesday, May 8, 2018 2:53 PM > To: dev-bounces@dpdk.org > Cc: Andy Green ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 09/18] drivers: net: qede: fix strncpy con= stant > and NUL >=20 > 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] > > > =3D '\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 li= ke you did. >=20 > Can that actually be fixed inside OSAL_STRNCPY itself, rather than having= each > use needing to explicitly null-terminate? Although there is only instance of OSAL_STRNCPY, it makes sense to modify i= t. Thanks, Shahed