From patchwork Mon Jul 23 22:37:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10541263 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91E0513BB for ; Mon, 23 Jul 2018 22:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 812F72855D for ; Mon, 23 Jul 2018 22:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74E0028573; Mon, 23 Jul 2018 22:37:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A10D2855D for ; Mon, 23 Jul 2018 22:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388109AbeGWXkZ (ORCPT ); Mon, 23 Jul 2018 19:40:25 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:41161 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388088AbeGWXkZ (ORCPT ); Mon, 23 Jul 2018 19:40:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1532385422; x=1563921422; h=from:to:cc:subject:date:message-id; bh=2BzUEBNQnuzOHvHzMZDukiLAP25o6IU4riTfDjXRRCM=; b=HyuzOia0sMhaAM1HCcyz0aPKE7vIMBoHIeswW/1GbGvrl5MjlXkrmd4j fjzO8BI6iUpIDMCoxZ8tZ6y38Rdy63I2c19TZNCkPy6MZrNmkvvSvBqQy FSwTM4ZPT5BCszl1nsU5mUSvAZWcKDwHZGoxJw1wHcEUkXiGTqOZ9lGRS MXDgbwRL2sEqtSRgBeok7hloT7miJ+X6NJq7CTLpGnvFR4wRfJWaDm2et FJ82KhYZO7Nbpu7LVTj5LS4ExhfC57pHeLTB+sfJQ7ZkmkUFTLYSSkNH8 Jqt6VcOiT7uTMs5DhvsUcHhi6/8EENVrOGx6UHnXSEmQKrNisGAcqBOC/ Q==; X-IronPort-AV: E=Sophos;i="5.51,394,1526313600"; d="scan'208";a="188429141" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2018 06:37:01 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 23 Jul 2018 15:25:11 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip02.wdc.com with ESMTP; 23 Jul 2018 15:37:01 -0700 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Christian Benvenuti Subject: [PATCH v3] RDMA/usnic: Suppress a compiler warning Date: Mon, 23 Jul 2018 15:37:01 -0700 Message-Id: <20180723223701.21086-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch avoids that the following compiler warning is reported when building with gcc 8 and W=1: drivers/infiniband/hw/usnic/usnic_fwd.c:95:2: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 20 [-Wstringop-truncation] strncpy(ufdev->name, netdev_name(ufdev->netdev), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sizeof(ufdev->name) - 1); ~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Bart Van Assche Cc: Christian Benvenuti --- drivers/infiniband/hw/usnic/usnic_fwd.c | 4 ++-- drivers/infiniband/hw/usnic/usnic_fwd.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/usnic/usnic_fwd.c b/drivers/infiniband/hw/usnic/usnic_fwd.c index 995a26b65156..7875883621f4 100644 --- a/drivers/infiniband/hw/usnic/usnic_fwd.c +++ b/drivers/infiniband/hw/usnic/usnic_fwd.c @@ -92,8 +92,8 @@ struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev) ufdev->pdev = pdev; ufdev->netdev = pci_get_drvdata(pdev); spin_lock_init(&ufdev->lock); - strncpy(ufdev->name, netdev_name(ufdev->netdev), - sizeof(ufdev->name) - 1); + BUILD_BUG_ON(sizeof(ufdev->name) != sizeof(ufdev->netdev->name)); + strcpy(ufdev->name, ufdev->netdev->name); return ufdev; } diff --git a/drivers/infiniband/hw/usnic/usnic_fwd.h b/drivers/infiniband/hw/usnic/usnic_fwd.h index 0b2cc4e79707..f0b71d593da5 100644 --- a/drivers/infiniband/hw/usnic/usnic_fwd.h +++ b/drivers/infiniband/hw/usnic/usnic_fwd.h @@ -57,7 +57,7 @@ struct usnic_fwd_dev { char mac[ETH_ALEN]; unsigned int mtu; __be32 inaddr; - char name[IFNAMSIZ+1]; + char name[IFNAMSIZ]; }; struct usnic_fwd_flow {