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 CF8E2A0542; Tue, 31 May 2022 11:22:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8134400EF; Tue, 31 May 2022 11:22:49 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by mails.dpdk.org (Postfix) with ESMTP id D7960400D6 for ; Tue, 31 May 2022 11:22:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biYysh8EzsxP9uNsRD+sMrur+fmAZ7gTDMCTYTr4CNrjZBO09Eu+Qkq9rLzuA3DQmiKpIT0w1xSL/5eSGirp9+jf+JH++1vbhxFQABm4yA44D8XNruqtfssmeBTvHW7dULOnBJEdeGfHQp4uM/N+DsRg25l5Jzc4tijwNZXo3YU6nmadZdCuWNyYiJjSTijOjZBqfAFcbGFKJ53eaiLkOjIinmvIavsDa10uRcWAdBngXDpKJB/tFd/tEiyfFnfsSSje/0YOW6fuKb9Rgc0gy7pX+Mr4pN8dB+OGz+G7lkDMZ1j12BZvTa2FyRTz7YHA/Uxnfzsq13LOxgWf0tXRTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r5e+8JTbpV1rlaG9aICw4NFtGops/HyKtTk42zlscnI=; b=Ve8wNyy1uyG+zGKKAri+wpzLzkCVsAPM8RuALUEbIFWdnb6ERl3WV5fbn0AQ5vK4DG+Q4A48sLNRfxpCgHDOKheKIyTh3kVzZqDMM/JPwnTGfaZrtlTmfysVdF55tAlCHiuJ0020gRG62Jqo6F4pCN73bIFj+hFTF/5DJib06hhlOeZmwM41650HggqbcT7GgxVf8r/t3gvpSiaueCBQTXNcwrrDHow6VU1ktl/URM8cnmkgHMOH4kHI3InWYW83K9wCqsaMxrJnKb+xEIosWaw47ycQUcGlgjnPJbwLRMA36cridds+wOJxNmb/sPM/qya43Zp786nwXDaY7gaU6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=intel.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r5e+8JTbpV1rlaG9aICw4NFtGops/HyKtTk42zlscnI=; b=KJCpp32NlGXm5wCv7J5vLxExXZCm/TN9OhD0NVFesw31KvkURGKfc8cD+L8WK9WH+WOxg2y/s2qtEQRrPiOU3xcjT4pBGjQourGCmGqW/gJBOLEJrPFvObOyPxJwQ2ck26YLdKHm9B/Vy8XFKUqiFlIKFFUEg+pSNbklyqJxPJg= Received: from DS7PR03CA0220.namprd03.prod.outlook.com (2603:10b6:5:3ba::15) by CH2PR02MB6822.namprd02.prod.outlook.com (2603:10b6:610:a5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.15; Tue, 31 May 2022 09:22:46 +0000 Received: from DM3NAM02FT004.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::9a) by DS7PR03CA0220.outlook.office365.com (2603:10b6:5:3ba::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.16 via Frontend Transport; Tue, 31 May 2022 09:22:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch02.xlnx.xilinx.com; pr=C Received: from xir-pvapexch02.xlnx.xilinx.com (149.199.80.198) by DM3NAM02FT004.mail.protection.outlook.com (10.13.5.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5293.13 via Frontend Transport; Tue, 31 May 2022 09:22:46 +0000 Received: from xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 31 May 2022 10:22:45 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 31 May 2022 10:22:45 +0100 Envelope-to: bruce.richardson@intel.com, ke1x.zhang@intel.com, dev@dpdk.org, stephen@networkplumber.org Received: from [10.71.116.69] (port=3235) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nvy5N-0005Dd-7Y; Tue, 31 May 2022 10:22:45 +0100 Message-ID: <8f8e001c-168e-0bb0-65b3-9f4ad9c94716@xilinx.com> Date: Tue, 31 May 2022 10:22:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] examples/kni: clear warning about discarding const qualifier Content-Language: en-US To: Bruce Richardson , Ke Zhang CC: , References: <20220531081304.229902-1-ke1x.zhang@intel.com> From: Ferruh Yigit In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e8e6064a-7298-416f-0ab8-08da42e71fd8 X-MS-TrafficTypeDiagnostic: CH2PR02MB6822:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZzCt5u2492d/AwUnIEZtTPGEnPirxqhO5Nhll0+Wt7XWATC1Qb+pue/fZ+9KayA+OgNnldZ2Ulu/FfyuwwrnTXe46jBjXVIigkg9nD6LByR5YYCk1scNwnSx7aX3Ya9UED8+q0SPEER2P30g8jeu1gpxt+ZD3obWLT9dLSdKZk7impFbdOdgzOInyyQ+JJkDxyudjceKUpVRWcecVNgqDncUW6WQ9dUT3/Su6usWNcZ9wzsEZjO0gACutv2wCHcREr2h7VxbX8zdb59P9HdjB1oBG0ZIhsxzfxNKD5joHBwQhtRHcB+6KdZR/iOgLZDonHcuNtZPZ1O/4m8wCxaZnoirKaodDNxhrrNtrIE5TY8BF/qzBdrZMU9HZkCqOVvt2/ZQhJeS5c40W7G7sxWIDIo4/EguVLQgA5JLirW+YZThaKTpyAj2MNvcUeSBIVICxik+8IOy9Em3kwZYEfYiJFEiS2OpUiYQz0zlsPIgSYBqhu+xCQlDk+e40gcTj/Jpgh1sbBo1KSjNcLrC7/Hn84KklZMD4pN72JtXIKSeFv8mdNKLQWJcO9zeLMXcvAeR5KXuFf0/yCUZg12fMfpMATrUnptRVjaYdQdYWh3EGsI8HqoM1rQUt4vnI1TGcIIqfcTELfG7Jqe8qHPSsP+3D/+kZBrzH3MU7rRSMQfsO/EEfMOATi9V8yJQ/zaepNk6OuuH0iX2SjxahVxJ9h5L+YBL5PtP+uCCre7f88ah5mA= X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch02.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(356005)(26005)(53546011)(186003)(82310400005)(2906002)(426003)(336012)(47076005)(36860700001)(9786002)(4326008)(508600001)(54906003)(2616005)(31686004)(36756003)(8936002)(8676002)(31696002)(40460700003)(110136005)(316002)(70206006)(70586007)(5660300002)(44832011)(83380400001)(7636003)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2022 09:22:46.3289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8e6064a-7298-416f-0ab8-08da42e71fd8 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT004.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR02MB6822 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 5/31/2022 10:12 AM, Bruce Richardson wrote: > [CAUTION: External Email] > > 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? > Agree that this is not proper fix. Variable seems done const intentionally to prevent using it directly, there are new helper functions like 'eth_hw_addr_set()', 'eth_hw_addr_random()', .. to use with newer kernel versions.