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 62A00A0032; Wed, 11 May 2022 18:42:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20AD6406B4; Wed, 11 May 2022 18:42:11 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by mails.dpdk.org (Postfix) with ESMTP id 7633D40042; Wed, 11 May 2022 18:42:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WgPF4Go5+ju7AKg8CukIENsuTkRfsW4Y2OPo8YiYNjUNlAAesfRVpmVz4jag7RkapdgMs9jSUfZ1inSNcP9YxhNfS540KzzOIif22SwoFoL3vtrvix8GJfYJHPGtvt7SLe/17dZ5PTfn94shwT7fVaYtx8nbPrZvScvfk9QoE47+ks91iOJtkgSTKqInKey/A4qY3NfNVOugihMlerHjvt8+18XS6V1zW4G0nafBZNI9SeIssO96s1dJVAgckwoAvqa7xsAQRIxdR59nbJVDCzvTLlHb7PalD/1VaX0jeZN8HPZAPKHY8uIrIslliLQMM6EAbxZOGRBER6rZC9TtSw== 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=HsD2ZMjkYhVIMuQdJ7c4xn1vCx4Vc2FRzgs2LWhTC5k=; b=AZu0kNF1NMXq+wnEgLBT0eRkqDpoIRlSNaXwsqr31O7g8SIVu9B/gH1aWH/4gy9itDs9UPDs0/xa6L8dXDoHMjYAYQSaCZTLtv0guVF1J9sZ349a1e+80sBZVuZ7weAMU+9+cfmDkfanOAgBXJJkTCFhi2HBgnStIp1Fwr7eSJSLX772sRqk9SPNuggJEnydtcoP+o1mlh1oUBNBck1WY3eiius05MUTURJ9aNDHfVd1rsPwRFcb9L7kt4AQRGEMCJ1S89XCpS0yEfZRrU6gx5fGok91vAD6vyvQd4pXUB7j/SY6CWwemmBhNgnubppZrQreZSimMT1krHETOmZUCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HsD2ZMjkYhVIMuQdJ7c4xn1vCx4Vc2FRzgs2LWhTC5k=; b=iu0/1SJrNu5EuBVsPyT5LNJvX2wLQaN9dJIOJlp+KOtg7+Vl5pZIUdmYBjEnHGkgM4Oa0gYwmwhrq6IhzeTbOnflrOnh4T+ARYVpLJzWD3YgB2cF/vOSfyouV0IU2RFW8vdvtUfd0IgtVFT9Jx7PXtOtqx7HVuPkFhyzjkrFwkWrY3Bz/X4lSu2q3KSEtQPcXHOyUrsuu2GNJ4AIx5VgurxzLO9pg0VvqV41yxDWSlXo9d47W1CO/8MKQ+TvQ3ai1NTwKaKX/bFwWGuQsC9kIbjwiwvwA7GvjfsuMszSFt2umxLLgagei96N7W2fvHqcCvxWHTyEF5cN00L7oI+YGg== Received: from BN8PR04CA0025.namprd04.prod.outlook.com (2603:10b6:408:70::38) by CH2PR12MB4807.namprd12.prod.outlook.com (2603:10b6:610:a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Wed, 11 May 2022 16:42:08 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::bc) by BN8PR04CA0025.outlook.office365.com (2603:10b6:408:70::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 16:42:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 16:42:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 11 May 2022 16:42:05 +0000 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 11 May 2022 09:42:04 -0700 From: Ali Alnubani To: CC: , Subject: [PATCH v2] net/mlx5: fix build with clang 14 Date: Wed, 11 May 2022 19:41:09 +0300 Message-ID: <20220511164109.1574109-1-alialnu@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220511135815.1564053-1-alialnu@nvidia.com> References: <20220511135815.1564053-1-alialnu@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44ebded1-be00-470b-4c24-08da336d3025 X-MS-TrafficTypeDiagnostic: CH2PR12MB4807: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: G1dz1LjtZQvtqA1A+bQa5rJNWZugC4a/Yguah/Sw8wdfRRj+BC42EGqUjxiNOOKvS2Or8s2gLyifAtUSXWudP29RXX4nURZyHkEO7HMo1VlBRzHfZZKJTlifDaBCze9WykzKF21gjqOH/VBvDvQlKbYEjYqFXk5m+A1BL8G/c27RIyMGrNepmZQavDCwT2Y37xd/GXV3fvWq45erfBd0SygA6hbFNLxsutMgxU2fp3G4XwzjIYOMzO/QtbgMUOZoZz7ikHpAYMZUxlUmcpRdOPO76Jf/Xnp8dCTFjVn2kUom2g0/9OHxWh2e++6dVSBKBJFXv9OTqqXIqXfXtxiprNqpwYeAZyHMwnQ6OLNunag7uWZxYBhzBw21wOmEKlNk7WL7axyvgB8iB7b2mR1VY4uSDIEf1x5K6SHexxh6+FXWc5rUfJm0jCPq27aliJJ0axECziYRW/dxIRwMTmqAdqvnod3Jn4ET9oj73oPfuyxfHJYTuGynO/18Iu0PxFtGJORbsKmH9NKFWwdidD0crDfZY1nJvHgrfQXjGAfkH3VlCIEt7W2bs8qlRpvQsXfhnW70zhXPvaOnJyMloS854FqlX5pbJ0lLrtzrZGXgkCPq+qRtTPExQRvBMICjHEQXbc/wWnP0hPZhtXnRxu2TH9zqIuajn9uFfbdsY7QFhpp0+oYYS16O9Nbl2rUu2FySf8cMpMXx9APqc/pKK3Gw1A== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(36756003)(82310400005)(450100002)(356005)(2616005)(81166007)(55016003)(8936002)(316002)(83380400001)(6916009)(70206006)(54906003)(4326008)(70586007)(8676002)(6286002)(426003)(47076005)(336012)(40460700003)(36860700001)(26005)(508600001)(2906002)(5660300002)(1076003)(186003)(16526019)(86362001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 16:42:07.6830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44ebded1-be00-470b-4c24-08da336d3025 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4807 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 Use fgets instead of fscanf to resolve the following warning reported by clang 14.0.0 in Fedora 37 (Rawhide): drivers/net/mlx5/linux/mlx5_ethdev_os.c:1137:52: error: 'fscanf' may overflow; destination buffer in argument 3 has size 16, but the corresponding specifier may require size 17 [-Werror,-Wfortify-source] ret = fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", port_name); Fixes: 63d1db710fbc ("net/mlx5: fix unlimited parsing of switch info") Cc: michaelba@mellanox.com Cc: stable@dpdk.org Signed-off-by: Ali Alnubani --- Changes in v2: - Removed unnecessary variable. drivers/net/mlx5/linux/mlx5_ethdev_os.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 8fe73f1adb..4db94c5917 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1118,7 +1118,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) bool port_switch_id_set = false; bool device_dir = false; char c; - int ret; if (!if_indextoname(ifindex, ifname)) { rte_errno = errno; @@ -1134,10 +1133,9 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) file = fopen(phys_port_name, "rb"); if (file != NULL) { - ret = fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", port_name); - fclose(file); - if (ret == 1) + if (fgets(port_name, IF_NAMESIZE, file) != NULL) mlx5_translate_port_name(port_name, &data); + fclose(file); } file = fopen(phys_switch_id, "rb"); if (file == NULL) { -- 2.25.1