DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] examples/kni: clear warning about discarding const qualifier
@ 2022-05-31  9:13 Ke Zhang
  2022-05-31 14:55 ` Stephen Hemminger
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Ke Zhang @ 2022-05-31  9:13 UTC (permalink / raw)
  To: ferruh.yigit, dev; +Cc: Ke Zhang

The warning info:
warning: passing argument 1 of ‘memcpy’ discards ‘const’
qualifier from pointer target type

Compulsory type conversion to clear compile warning.

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..6f9dab4732 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);
+		memcpy((unsigned char *)net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN);
 	else
 		/* Generate random MAC address. */
-		eth_random_addr(net_dev->dev_addr);
+		eth_random_addr((uint8_t *)net_dev->dev_addr);
 
 	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..fd54b6fe0f 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);
+	memcpy((unsigned char *)netdev->dev_addr, addr->sa_data, netdev->addr_len);
 
 	ret = kni_net_process_request(netdev, &req);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 19+ messages in thread
* [PATCH] examples/kni: clear warning about discarding const qualifier
@ 2022-05-31  8:13 Ke Zhang
  2022-05-31  9:12 ` Bruce Richardson
  0 siblings, 1 reply; 19+ messages in thread
From: Ke Zhang @ 2022-05-31  8:13 UTC (permalink / raw)
  To: ferruh.yigit, dev; +Cc: Ke Zhang

The warning info:
warning: passing argument 1 of ‘memcpy’ discards ‘const’
qualifier from pointer target type

Compulsory type conversion to clear compile warning.

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 kernel/linux/kni/kni_misc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index 780187d8bf..6f9dab4732 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);
+		memcpy((unsigned char *)net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN);
 	else
 		/* Generate random MAC address. */
-		eth_random_addr(net_dev->dev_addr);
+		eth_random_addr((uint8_t *)net_dev->dev_addr);
 
 	if (dev_info.mtu)
 		net_dev->mtu = dev_info.mtu;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-06-08 17:23 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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-05-31  8:13 [PATCH] examples/kni: clear warning about discarding const qualifier Ke Zhang
2022-05-31  9:12 ` Bruce Richardson
2022-05-31  9:22   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).