From: Ferruh Yigit <ferruh.yigit@xilinx.com>
To: Ke Zhang <ke1x.zhang@intel.com>, <dev@dpdk.org>
Cc: <stable@dpdk.org>
Subject: Re: [PATCH v2] examples/kni: clear warning about discarding const qualifier
Date: Wed, 1 Jun 2022 16:44:17 +0100 [thread overview]
Message-ID: <421c3763-d4b0-aee5-eadf-d37e9a60a816@xilinx.com> (raw)
In-Reply-To: <20220601054525.7573-1-ke1x.zhang@intel.com>
On 6/1/2022 6:45 AM, Ke Zhang wrote:
> 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 <ke1x.zhang@intel.com>
> ---
> 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);
>
Hi Ke,
We can't just use new APIs, otherwise this will fail with old kernels.
A version check is needed, please check 'compat.h' for various samples.
next prev parent reply other threads:[~2022-06-01 15:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 9:13 [PATCH] examples/kni: clear warning about discarding const qualifier Ke Zhang
2022-05-31 14:55 ` Stephen Hemminger
2022-06-01 5:45 ` [PATCH v2] " Ke Zhang
2022-06-01 15:44 ` Ferruh Yigit [this message]
2022-06-05 9:47 ` [PATCH v3 1/2] kni: use dedicated function to set random MAC address Andrew Rybchenko
2022-06-05 9:47 ` [PATCH v3 2/2] kni: fix warning about discarding const qualifier Andrew Rybchenko
2022-06-08 11:13 ` [PATCH v4 0/2] kni: fix build warnings with Linux 5.17+ Andrew Rybchenko
2022-06-08 11:13 ` [PATCH v4 1/2] kni: use dedicated function to set random MAC address Andrew Rybchenko
2022-06-08 11:13 ` [PATCH v4 2/2] kni: fix warning about discarding const qualifier Andrew Rybchenko
2022-06-08 12:11 ` [PATCH v5 0/2] kni: fix build warnings with Linux 5.17+ Andrew Rybchenko
2022-06-08 12:11 ` [PATCH v5 1/2] kni: use dedicated function to set random MAC address Andrew Rybchenko
2022-06-08 12:52 ` Ferruh Yigit
2022-06-08 12:11 ` [PATCH v5 2/2] kni: fix warning about discarding const qualifier Andrew Rybchenko
2022-06-08 12:54 ` Ferruh Yigit
2022-06-08 13:10 ` Ferruh Yigit
2022-06-08 17:23 ` [PATCH v5 0/2] kni: fix build warnings with Linux 5.17+ Andrew Rybchenko
-- strict thread matches above, loose matches on Subject: below --
2022-06-01 3:24 [PATCH v2] examples/kni: clear warning about discarding const qualifier Ke Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=421c3763-d4b0-aee5-eadf-d37e9a60a816@xilinx.com \
--to=ferruh.yigit@xilinx.com \
--cc=dev@dpdk.org \
--cc=ke1x.zhang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.