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 2BCE9A0542; Tue, 31 May 2022 11:13:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D473400EF; Tue, 31 May 2022 11:13:02 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 3BAC4400D6 for ; Tue, 31 May 2022 11:13:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653988380; x=1685524380; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=RMU4dSAhtq7hhv8p1CsrJ5ZdxFdG4a35gZTA3a/x1cA=; b=e5xnFuy+osBJwu9ZZS+YDq4nAD5K/lIujhnUU7lIt+AwFW5EF7+KKINx 8ePFJfjDJI7WBehW8QbJnK5BNr8V7LYeuRnW3r97CfoC2ooJdtofZ0EgL 2mSnBqMVeif4tN/84MQSM96G2g0j+eiiciRrqijoleYxa6Hdz2aTeO3+l BxQGDjssKtYMPlbQToYHFLupVGaYqZaOnSmygeMkp8+k06zyHYpKzGaEl I7ebx1bLkwkM9dPBN9Ng/EPBaV8EnfV5eJEfApLyCb4GHiV1mUmC9f1Sd claXk4ooMME8OND5iLSGAc1bvW1EJgzHbDTym+dJPtlHJr70lFY6kRJAa g==; X-IronPort-AV: E=McAfee;i="6400,9594,10363"; a="275280595" X-IronPort-AV: E=Sophos;i="5.91,264,1647327600"; d="scan'208";a="275280595" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 02:12:37 -0700 X-IronPort-AV: E=Sophos;i="5.91,264,1647327600"; d="scan'208";a="632950559" Received: from bricha3-mobl.ger.corp.intel.com ([10.55.133.25]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 31 May 2022 02:12:36 -0700 Date: Tue, 31 May 2022 10:12:32 +0100 From: Bruce Richardson To: Ke Zhang Cc: ferruh.yigit@intel.com, dev@dpdk.org, stephen@networkplumber.org Subject: Re: [PATCH] examples/kni: clear warning about discarding const qualifier Message-ID: References: <20220531081304.229902-1-ke1x.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220531081304.229902-1-ke1x.zhang@intel.com> 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 On Tue, May 31, 2022 at 08:13:04AM +0000, Ke Zhang wrote: > 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 > --- > 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; +Stephen H on CC, for his advice This fix seems wrong to do. Given that it's a pointer to const char* rather than an actual array in the structure, is a better fix not to point the pointer to a new area of memory rather than trying to overwrite the old one? /Bruce