From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 44C031B4D0; Tue, 26 Jun 2018 12:38:37 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 03:38:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,274,1526367600"; d="scan'208";a="49979389" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.212]) by fmsmga007.fm.intel.com with ESMTP; 26 Jun 2018 03:38:26 -0700 From: Ferruh Yigit To: Ferruh Yigit Cc: dev@dpdk.org, stephen@networkplumber.org, pablo.de.lara.guarch@intel.com, stable@dpdk.org Date: Tue, 26 Jun 2018 12:38:07 +0100 Message-Id: <20180626113807.67100-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <07e4d536-edd6-292d-5adb-c05793731623@intel.com> References: <07e4d536-edd6-292d-5adb-c05793731623@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3] kni: fix build with gcc 8.1 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, 26 Jun 2018 10:38:39 -0000 Error observed when CONFIG_RTE_KNI_KMOD_ETHTOOL config option is enabled. build error: In function ‘strncpy’, inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixed by using strlcpy instead of strncpy. adapter->fw_version size kept same because of c3698192940c ("kni: fix build with gcc 7.1") Also next line strncpy usage replaced with strlcpy while arround. Fixes: c3698192940c ("kni: fix build with gcc 7.1") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit --- v2: * used strlcpy instead of strncpy * Updated strncpy usage in next line to strlcpy too * Added fixes line v3: * fix patch syntax corrupted during send --- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/linux/kni/ethtool/igb/igb_ethtool.c b/kernel/linux/kni/ethtool/igb/igb_ethtool.c index 064528bcf..002f75c48 100644 --- a/kernel/linux/kni/ethtool/igb/igb_ethtool.c +++ b/kernel/linux/kni/ethtool/igb/igb_ethtool.c @@ -811,9 +811,10 @@ static void igb_get_drvinfo(struct net_device *netdev, strncpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver) - 1); strncpy(drvinfo->version, igb_driver_version, sizeof(drvinfo->version) - 1); - strncpy(drvinfo->fw_version, adapter->fw_version, - sizeof(drvinfo->fw_version) - 1); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), sizeof(drvinfo->bus_info) -1); + strlcpy(drvinfo->fw_version, adapter->fw_version, + sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = IGB_STATS_LEN; drvinfo->testinfo_len = IGB_TEST_LEN; drvinfo->regdump_len = igb_get_regs_len(netdev); -- 2.17.1