From patchwork Wed Jul 18 16:01:35 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: 10532759 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.web.codeaurora.org (Postfix) with ESMTP id 1196B601D2 for ; Wed, 18 Jul 2018 16:01:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01C3529911 for ; Wed, 18 Jul 2018 16:01:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7ABB29966; Wed, 18 Jul 2018 16:01:40 +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 8773329911 for ; Wed, 18 Jul 2018 16:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729775AbeGRQkM (ORCPT ); Wed, 18 Jul 2018 12:40:12 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:65423 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726402AbeGRQkM (ORCPT ); Wed, 18 Jul 2018 12:40:12 -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=1531929699; x=1563465699; h=from:to:cc:subject:date:message-id; bh=s/yPyW0ohXx4z23vQ+xdFI5zUYQHaPVO1tpslDvFpW4=; b=Uyg2cExPKZq4xCAOSgQ6ssVismy42eqSVe3foPC0wlbLq4ekFa7rDqzf q6QEoOkiSsibly6eLoouwIyVvB4vMcIZfZ51TQ8uHF9oD4oZeWH66t1+L d2RxCVp++3DSBUZnXmIS0aKSMtX0HIjFBJrTrAAtQRXFDymOLWlGRtdwW 21XEaimgyGBRoREr9chi94/PAj4ZBAHrknfjN1v0VKmSCeKi9S0kI32Cg sO9EwbQ06dI3T8KByf7O9Pvq5MvGavARvTvds5yg8mdqsES7dLji6OIhY zP4EuifRqYdXXjaGzEHulpIX8lskiuN8vTlxfnr5k6q9mILiMdzrgdeWm A==; X-IronPort-AV: E=Sophos;i="5.51,370,1526313600"; d="scan'208";a="87579418" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jul 2018 00:01:36 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 18 Jul 2018 08:50:25 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip01.wdc.com with ESMTP; 18 Jul 2018 09:01:35 -0700 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Selvin Xavier , Devesh Sharma Subject: [PATCH] RDMA/ocrdma: Suppress a compiler warning Date: Wed, 18 Jul 2018 09:01:35 -0700 Message-Id: <20180718160135.11738-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: In function 'ocrdma_mbx_get_ctrl_attribs', inlined from 'ocrdma_init_hw' at drivers/infiniband/hw/ocrdma/ocrdma_hw.c:3224:11: drivers/infiniband/hw/ocrdma/ocrdma_hw.c:1368:3: warning: 'strncpy' output may be truncated copying 31 bytes from a string of length 31 [-Wstringop-truncation] strncpy(dev->model_number, ^~~~~~~~~~~~~~~~~~~~~~~~~~ hba_attribs->controller_model_number, 31); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Bart Van Assche Cc: Selvin Xavier Cc: Devesh Sharma Acked-by: Selvin Xavier --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index c6c87cba943b..e578281471af 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1365,8 +1365,9 @@ static int ocrdma_mbx_get_ctrl_attribs(struct ocrdma_dev *dev) dev->hba_port_num = (hba_attribs->ptpnum_maxdoms_hbast_cv & OCRDMA_HBA_ATTRB_PTNUM_MASK) >> OCRDMA_HBA_ATTRB_PTNUM_SHIFT; - strncpy(dev->model_number, - hba_attribs->controller_model_number, 31); + strlcpy(dev->model_number, + hba_attribs->controller_model_number, + sizeof(dev->model_number)); } dma_free_coherent(&dev->nic_info.pdev->dev, dma.size, dma.va, dma.pa); free_mqe: