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 DE3BFA0548; Wed, 1 Jun 2022 17:44:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE5D140689; Wed, 1 Jun 2022 17:44:23 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) by mails.dpdk.org (Postfix) with ESMTP id DF1EA4113F; Wed, 1 Jun 2022 17:44:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IWPaaCIDExuCHbnyofIEjWclmlPnaJKwSu776rVfI6LDGWbjr4k1AbgIqvbuCGmAsOsnxbBvckxmMn6f8gVDy5pNFiGRilO3AuUWlcnAkmkmv4zrS+bImG7I9if117Z4YkIKbLALw/8tE/PKxwcUx3BQPLT3scJ0r8G9Dohv/kBhN9XTOoQg+pNcRdFysWWK91rvtRqYFesnqFiDx6W6pROinQPx+HQuAeQcH6f7Szk8IyTjK1R5Fj8G9kUY38YiQWreq/GuAXEnKCGAaxWmtWuM0NikU2Pdfzf0rm/DXwJgl/J7IDapwrATBEIMXjUzKfZE60TVsxzaaH4K+7ylcw== 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=w7oY3gQnpmPGG6r7t7bpNzfDE+ebEwzVp1O17eUjnxU=; b=eHVBMvYzizDxTcFn0lmUOGJ3LXXCiEgBPlyaa63/W4pOnttYPIjOiKNc2hIeo3tbKsyRAMW2v8G3TdtiM1nUHkMLurfWsqAls0Z3Au8cXCFJ4qptb2fQoI60Ray0fYkypBIdpo95lL+pGUxhMtcDqCLaN0hibjIiawAfNBb2LXjLtBxqVRkHRZl0NC5cEZUvIu7xjZs+hAqZe2FPAtv5UlNZG6Mc8EfwuhARUCPQdu70meah551AAJ4Cb4+TFTnb8Vdn/G5R05Rc/61Q0i0x8QuP8xtxnMk4Ucegy27sOSz7bzFV3I3n0XFJhYTHOLvWGhJQMuHA0Mfo/GI8EqIe0A== 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=w7oY3gQnpmPGG6r7t7bpNzfDE+ebEwzVp1O17eUjnxU=; b=UKnWlMCK/FvoXL7FJ1ZWMDQKSQXC5QmF93H3Fr1LKNo6k/9uVJxyPmJPIbtKTz30Bl2edFwgjZJ9PUtU4g6hohf/MiXr27EJ8ans4UsrRyc+f0VBsCNs9n+al+xP+CAl6qtRcbyX8YmuZwl9VYv8TTcEq8Z7pIaPhMZDfwZPONI= Received: from SN4PR0801CA0020.namprd08.prod.outlook.com (2603:10b6:803:29::30) by SJ0PR02MB8628.namprd02.prod.outlook.com (2603:10b6:a03:3fd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Wed, 1 Jun 2022 15:44:19 +0000 Received: from SN1NAM02FT0005.eop-nam02.prod.protection.outlook.com (2603:10b6:803:29:cafe::86) by SN4PR0801CA0020.outlook.office365.com (2603:10b6:803:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 15:44:19 +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 SN1NAM02FT0005.mail.protection.outlook.com (10.97.4.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 15:44:18 +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; Wed, 1 Jun 2022 16:44:17 +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; Wed, 1 Jun 2022 16:44:17 +0100 Envelope-to: ke1x.zhang@intel.com, dev@dpdk.org, stable@dpdk.org Received: from [10.71.119.122] (port=21005) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nwQW9-0007gV-AY; Wed, 01 Jun 2022 16:44:17 +0100 Message-ID: <421c3763-d4b0-aee5-eadf-d37e9a60a816@xilinx.com> Date: Wed, 1 Jun 2022 16:44:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2] examples/kni: clear warning about discarding const qualifier Content-Language: en-US To: Ke Zhang , CC: References: <20220531091330.230715-1-ke1x.zhang@intel.com> <20220601054525.7573-1-ke1x.zhang@intel.com> From: Ferruh Yigit In-Reply-To: <20220601054525.7573-1-ke1x.zhang@intel.com> 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: 5bc94295-3dee-477d-67d6-08da43e59726 X-MS-TrafficTypeDiagnostic: SJ0PR02MB8628: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: XjIJj7GiZG2cSaZGVc0Tw47SiBaUMowHWZ2otTmPsg9Nd888a6FThQFrfmEQVaI3oo/nIxT2B8hMmstbTgHJJUsh9KEegHf8MtykteLKJ3YXNHyadAz/DqbXaWIKyaASW4c6YUX8n0xkEAxAgHW5/AiqRsvN/3kq5mHaaY4gP+0mIhKyazykbkZd72Ukns5goi5h1bTtPaMUPWIxlGZqPiRjgWxwpVJ2qCFSE7x/XUnsGqv+1lQVz+U5QX78HvEBIe/NO6KYW3I0gChcPqC1gbPGlUOA0FnkjEaonnCNTKJQLJ2ItD1idFMl8TcWt+XZQBgiXqymq5Qyj76R7VYSA1t2AjxH62/QSvN22NcTA9v0xMSH67J0/gvDrwZ5xkIWPxvjg0P17w8/5fiKHG8w+4HraFwBWq3VZwm8ffXlmEVh+oQT8dCqX6kKT/eOecgM7pn1s+sG93tx13AYFD/uyICfvKZRpyiNecg7HfdkXpbRFZjAXh5Ie3M5GzEJ/owVsjjx2LCRsiywx/jr4+z3nx9DyjPJ3/o1rsvp8vn1PUlWTX3jzmC2g16LNtC6KFhcs5OtkAGUIOvCUAGiZkq34INmKuBzkjYnZ9aE6WaYdCe4xqY5xvZrxOC/VmU9Utxuk1tBntOnPVxrVKRBYXBKIIERY4pWf5ZiziInYKiyB37sueMwNfmEVkaW+o7HMqwgGdrmHApAJYNQwhk0FPvrBx3SiWm3rXxoP6PB0etqDfY= 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)(36840700001)(46966006)(40470700004)(26005)(186003)(53546011)(8936002)(36860700001)(110136005)(356005)(36756003)(7636003)(316002)(8676002)(31686004)(70206006)(4326008)(70586007)(508600001)(2906002)(5660300002)(82310400005)(426003)(336012)(40460700003)(83380400001)(9786002)(44832011)(31696002)(2616005)(47076005)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 15:44:18.6138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bc94295-3dee-477d-67d6-08da43e59726 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: SN1NAM02FT0005.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB8628 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 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 > --- > 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.