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 D0ACBA054F; Wed, 1 Jun 2022 07:51:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6336040A84; Wed, 1 Jun 2022 07:51:32 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 6502040150; Wed, 1 Jun 2022 07:51:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654062690; x=1685598690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4XmClkZzpArxXd1D1aSOWB6nbSSeMf9U8NFWEv8Yl8E=; b=XAtPZwdGu6ZobJgD9soXQ+mwvJwlp/A/yhwjTYyETKEuR0t0WQuIBO6S qtGDEVCP9TFaheUADZ4w365ABd6Udy2oHuWgtPJ8g6/VZMImWizYIKyJL 6EVAjXv80c85KxpmwsSjkAFVMtc+MwIFGDQ8xFSO4aNLK2rs979SNV3pP s1otmSlNUtyNpRuVqtjcjejWnM+c9TndeF7F87Cl1InfuimUwVdssS07s va+MfEkC/bhHDwBjCKhdI2WvhCioDqdXN0luEuWpO+Dap2tYdyMayovwK vBMO+ktYgj05uTtd6yt3yBphKqSCVEH2W3ucl3UgV+/SzKkDGYtSQlwJY Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="255958477" X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="255958477" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 22:51:29 -0700 X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="606080279" Received: from unknown (HELO localhost.localdomain) ([10.239.251.104]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 22:51:27 -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 05:45:25 +0000 Message-Id: <20220601054525.7573-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531091330.230715-1-ke1x.zhang@intel.com> References: <20220531091330.230715-1-ke1x.zhang@intel.com> 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