From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F01C0A0552; Wed, 1 Jun 2022 05:30:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 919BE40A84; Wed, 1 Jun 2022 05:30:46 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 1B0A340150; Wed, 1 Jun 2022 05:30:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654054245; x=1685590245; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4XmClkZzpArxXd1D1aSOWB6nbSSeMf9U8NFWEv8Yl8E=; b=Et4KhctZNBtNx9bodFgLKcmbFMF+uj1R7qS8Dn7noYRHWPrBPn1ttjNH 17sWWsl8pWJCnLwrOZ5thzbRgEuYRx48EOcp1rbPSKMFCaEHXECDGu7Sa pCEWsB++RDaAVeDMIwxdCjrUeQMNb8Ik5DR0pjIOCyIHqM0OxUC4gooQF iSQ/nz7lMBViQwn7Dz0PqAj0Qzm7CyV14fYOh48CiaIWQpj897gKJ+WX1 qrg22ta//iEHLMdG+ChbmoIQ45i9cbrTzCDl+bGI4+rrw626yHtm0Q2+B KwoUnjqC4y4M4KNIku9pXSeFd/CIaufbmq5QxfoxG7m5eCVSiMWToJ5Cq A==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="275182517" X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="275182517" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 20:30:43 -0700 X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="576726777" Received: from unknown (HELO localhost.localdomain) ([10.239.251.104]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 20:30:42 -0700 From: Ke Zhang To: ferruh.yigit@intel.com, dev@dpdk.org Cc: Ke Zhang , stable@dpdk.org Subject: [PATCH v2] examples/kni: clear warning about discarding const qualifier Date: Wed, 1 Jun 2022 03:24:40 +0000 Message-Id: <20220601032440.6517-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The warning info: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type Variable is done const intentionally to prevent using it directly, using the new helper functions : 'eth_hw_addr_set()' and 'eth_hw_addr_random()' Fixes: ea6b39b5b847 ("kni: remove ethtool support") Cc: stable@dpdk.org Signed-off-by: Ke Zhang --- kernel/linux/kni/kni_misc.c | 4 ++-- kernel/linux/kni/kni_net.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index 780187d8bf..1da8e812b7 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -403,10 +403,10 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, /* if user has provided a valid mac address */ if (is_valid_ether_addr(dev_info.mac_addr)) - memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); + eth_hw_addr_set(net_dev, dev_info.mac_addr); else /* Generate random MAC address. */ - eth_random_addr(net_dev->dev_addr); + eth_hw_addr_random(net_dev); if (dev_info.mtu) net_dev->mtu = dev_info.mtu; diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index 29e5b9e21f..1da4f836aa 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -779,7 +779,7 @@ kni_net_set_mac(struct net_device *netdev, void *p) return -EADDRNOTAVAIL; memcpy(req.mac_addr, addr->sa_data, netdev->addr_len); - memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); + eth_hw_addr_set(netdev, addr->sa_data); ret = kni_net_process_request(netdev, &req); -- 2.25.1