From patchwork Mon Apr 11 15:15:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 109596 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9320CA00BE; Mon, 11 Apr 2022 17:18:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8594241611; Mon, 11 Apr 2022 17:18:37 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2075.outbound.protection.outlook.com [40.107.22.75]) by mails.dpdk.org (Postfix) with ESMTP id 6046B415D7 for ; Mon, 11 Apr 2022 17:18:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jmT00qdc0yN0q3CjT3KPRNzKCCB3GNqIiQ7fu/x/LjtIYojf8931aR95kzhI6JyDqiQQeK+3zRmnBmlL+8sY0LKBu3TxpMBex8PxM9jmkdRNCfPyfcso4UfuuDKUYvExepLwa4cVLv5S7IfTJ+BRb/YVzN1d7AFUErq3bKAshSRH1VjcaBdL6EghQproeVoEWvSkA+mF9aY/jbSdSY4tWtpTv7aHOBwPiSD9h1Sx+9ciapYVstPZ0NCK/qfuJ/DHPfg4LyK+WqDOFKoUtxOdgtwxgiKl0fZ5uRfRnytJgQl00G63zF0kQMM/65VF+0FM5BvHCS92kIkuipNPnOWkFw== 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=9t/hTjCAT0r0pT1YrTQwOHpzMcHrkNUGsWIL3KI0gJk=; b=h76aRImFIc6nDUoHzQGI5uQ4cQ1hhCu/05XmdhV2ZTCPAfNEjSA881jbU16roaWkoL3wVDY/zXnvwmB+YKLFsijSBPN2AQ4TdSERGNwIdWiLlEaei+/i80caXiglVrThgWbGuNXzUpVQvOChAL4unS51T/qFaLxJ3VWiZYhdRQhL/bVfU6kzVAEL46sSZQdHuEy5PhHAP55gT1irnZQlOVWhmGbSS4J2oWkeZcGIg7Zypu5FZsx0CTG2MMSPJ0Kqawd7jvIJYRbKBlooaPzkuAuD52JS1uMehRdWYxVDusdt4eGbIpfMq/1Vco+veZqUQcDr4vNyS5oRRUg70Pf7aQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=arm.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9t/hTjCAT0r0pT1YrTQwOHpzMcHrkNUGsWIL3KI0gJk=; b=ky1wpchbEwHAatu6YNBFc7fuJYh4UU+U57yaFxRxewmBdu3mFPgZicZHY9KfGskGzi23NojBOPR0vZ/wH73bcPkaCrGUh+9xoRybY71K5qEFe/J7eP8oHzF1rR8DRW9604G9DNfLyKdlPWUY4QY/cApFxHN++0p9shjVOuRFU+Y= Received: from AM6P195CA0042.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::19) by HE1PR0702MB3657.eurprd07.prod.outlook.com (2603:10a6:7:7e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.17; Mon, 11 Apr 2022 15:18:35 +0000 Received: from VE1EUR02FT048.eop-EUR02.prod.protection.outlook.com (2603:10a6:209:87:cafe::50) by AM6P195CA0042.outlook.office365.com (2603:10a6:209:87::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29 via Frontend Transport; Mon, 11 Apr 2022 15:18:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by VE1EUR02FT048.mail.protection.outlook.com (10.152.13.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.5144.20 via Frontend Transport; Mon, 11 Apr 2022 15:18:34 +0000 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSMR505.ericsson.se (153.88.183.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.27; Mon, 11 Apr 2022 17:17:37 +0200 Received: from seliiuapp00218.seli.gic.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.189) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Mon, 11 Apr 2022 17:17:37 +0200 Received: from localhost.localdomain (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliiuapp00218.seli.gic.ericsson.se (Postfix) with ESMTP id 4ED9160160; Mon, 11 Apr 2022 17:17:37 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: Bruce Richardson , Thomas Monjalon , David Marchand , , , , Stephen Hemminger , =?utf-8?q?Mattias_R=C3=B6nn?= =?utf-8?q?blom?= Subject: [PATCH 1/3] eal: add macro to warn for unused function return values Date: Mon, 11 Apr 2022 17:15:57 +0200 Message-ID: <20220411151559.164217-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 79926fc1-27c6-4ff1-2d44-08da1bce8b87 X-MS-TrafficTypeDiagnostic: HE1PR0702MB3657: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: WzLrW3zhPIiL3Uyqr92+MrykT8UOZnGqZJzyygcDdiVRqr5V8qZtKfON3rYBpjYuL33seMhy++2ddndhgunwujMGtBA6HN4n1i+0KGwcr4srmr/9N4GEkeuJmFY/2K3Secv0Yxg1lIOo+OS96LGNp2su7iq0HB45UGfilrabbU7BY74+n1EAjZIzpPmUSMXDYUHM0HJVd+3DBF/52xCsinbVT8l8560u1avMVLugAN6Zu6ZshygCgtT3xfhzVuDuHsz+T/cZrFrsDza+kVUrTRHLKXI6HliqDRePlfSTqsKCcdXXIZ8NF05+RthYrhlKTAUvbNPHPCnrnrBYadDO8oobeXq5wo52UQJLBbvyH048rxYQWp/gtjhyUUcFNDKCHau2Gl014To7ebL2lRAK25NAu34t3qJ/0hxBfVepXklLCNTdlkQj15zJzMIQ312mRbtYQPuFvhtazCR0tDgDz+0vwWlGH9QUQehL/0fBud4FWsSYyv2r8jgZGvtFJLSQDy8iU9BcR3tuP0fYbOsiZ7sIIXUDnKzqxJbgVas5b5MVOHdhL1xkehbDMjirkTaMvAK96jxGgIu+tdKZ2zZYXVp/whqsnqj8TVhCE1pR9ckVXDXpF9ekBb7cZelz0JwjjETgEHG+91TALtp6uaZTNzwDVKUK1aN1DY6PWcYrfe8ERsirJavWVZSzDaeMNiEL X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(6666004)(316002)(47076005)(54906003)(6916009)(2906002)(36860700001)(186003)(107886003)(26005)(2616005)(6266002)(1076003)(66574015)(5660300002)(336012)(83380400001)(508600001)(40460700003)(8936002)(86362001)(4326008)(82310400005)(7636003)(82960400001)(356005)(8676002)(70206006)(36756003)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2022 15:18:34.3670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79926fc1-27c6-4ff1-2d44-08da1bce8b87 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT048.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0702MB3657 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 This patch adds a wrapper macro __rte_warn_unused_result for the warn_unused_result function attribute. Marking a function __rte_warn_unused_result will make the compiler emit a warning in case the caller does not use the function's return value. Changes since RFC: * Include usage recommendation and GCC peculiarities in the macro documentation. Acked-by: Bruce Richardson Signed-off-by: Mattias Rönnblom Reviewed-by: Morten Brørup --- lib/eal/include/rte_common.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 4a399cc7c8..67587025ab 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -222,6 +222,31 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) */ #define __rte_noreturn __attribute__((noreturn)) +/** + * Issue a warning in case the function's return value is ignored. + * + * The use of this attribute should be restricted to cases where + * ignoring the marked function's return value is almost always a + * bug. With GCC, some effort is required to make clear that ignoring + * the return value is intentional. The usual void-casting method to + * mark something unused as used does not suppress the warning with + * this compiler. + * + * @code{.c} + * __rte_warn_unused_result int foo(); + * + * void ignore_foo_result(void) { + * foo(); // generates a warning with all compilers + * + * (void)foo(); // still generates the warning with GCC (but not clang) + * + * int unused __rte_unused; + * unused = foo(); // does the trick with all compilers + * } + * @endcode + */ +#define __rte_warn_unused_result __attribute__((warn_unused_result)) + /** * Force a function to be inlined */ From patchwork Mon Apr 11 15:15:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 109594 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 67676A00BE; Mon, 11 Apr 2022 17:17:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E08A41611; Mon, 11 Apr 2022 17:17:51 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10050.outbound.protection.outlook.com [40.107.1.50]) by mails.dpdk.org (Postfix) with ESMTP id 1A888415D7 for ; Mon, 11 Apr 2022 17:17:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R79KGGnSpZu8Q/w1p34v0tboUH8NG77aoLgY9436TK9dgtAcNcogE2QqFaGUaEXP0urA0O8DP1sklIcu36+stBp/ETYpj21rjlTfeOO65wqyVaNhYjh+XTnyA1WDblcESi2Kpxpiu/AEIjJkwqOjK7L7Zl0486HLCQxPexhJktXlI73ehwKfCYXo/Br6T0zw1Kt2NKY6I0Fzf1p7BzvpglblgCSWhkNKtE/uUQuxt8QYLqsVIe2NuiVov9xBTdzIQmBKHcA20DM8yuflBPy82gle3mG972xjmgUO8qbXsNWSEqGFx9uNDyDpjHsxyEwcqkCl8inp4APFshPj+RbaaA== 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=V00tsxJT10IGhs6b1/zwptqPSUKuDm371CRj0rD4D60=; b=NzaZoyfq74qo7Gc3C08qdEaV5BNIN1pt1oPpNXBrmOAOn9Pmmz7tnuQZviXasYSFT2bqNSVroQPAWB4jXvlN2siRW9qatR97PEhZTfNdRxtiqhlp1/SAtfSFiEES1N2IWoFQRRTjNaYEqntqoahFwXjbMOhVivcUEhxFwsX3eEGbMKU/W8k5G7x5cditLKflDtWDhzii6athbXLvvOdnPkT8kwDPRhKGZXyAEmNoHEShYLRaUYKU4QDlpo/V82ZE2aznDaJnA3ts0xXpFndYJGwI6wGXRWuUPbww2/iSl5XFiABlpL92uPs0lNsb1n7NF61HGfE56oOTosRaZzIA1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=arm.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V00tsxJT10IGhs6b1/zwptqPSUKuDm371CRj0rD4D60=; b=sev8zpBrN0JL/uAXlxr/jw0ZoaM49PfgO/NS2rTtycj4Ag7zW3o7xLc9zZdoC8Nj8kzw/nJWIHeQCLJ/caANUU6/qfEWDqIIGXJ/LXUITwCmW/pv3RMnd+Etb9Akuso6ayWS48fjBvUY0dLD5TOEIhUMQWho5cxsHM0k8llMkcs= Received: from AS9PR06CA0414.eurprd06.prod.outlook.com (2603:10a6:20b:461::26) by AM0PR07MB5793.eurprd07.prod.outlook.com (2603:10a6:208:117::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.17; Mon, 11 Apr 2022 15:17:48 +0000 Received: from VE1EUR02FT040.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:461:cafe::45) by AS9PR06CA0414.outlook.office365.com (2603:10a6:20b:461::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29 via Frontend Transport; Mon, 11 Apr 2022 15:17:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by VE1EUR02FT040.mail.protection.outlook.com (10.152.13.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.5144.20 via Frontend Transport; Mon, 11 Apr 2022 15:17:47 +0000 Received: from ESESBMB504.ericsson.se (153.88.183.171) by ESESBMR501.ericsson.se (153.88.183.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.27; Mon, 11 Apr 2022 17:17:46 +0200 Received: from seliiuapp00218.seli.gic.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.187) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Mon, 11 Apr 2022 17:17:46 +0200 Received: from localhost.localdomain (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliiuapp00218.seli.gic.ericsson.se (Postfix) with ESMTP id 9544760160; Mon, 11 Apr 2022 17:17:46 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: Bruce Richardson , Thomas Monjalon , David Marchand , , , , Stephen Hemminger , =?utf-8?q?Mattias_R=C3=B6nn?= =?utf-8?q?blom?= Subject: [PATCH 2/3] eal: emit warning for unused trylock return value Date: Mon, 11 Apr 2022 17:15:58 +0200 Message-ID: <20220411151559.164217-2-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411151559.164217-1-mattias.ronnblom@ericsson.com> References: <20220411151559.164217-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8aefa276-91aa-489c-293a-08da1bce6fd8 X-MS-TrafficTypeDiagnostic: AM0PR07MB5793: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: OBJOUQTDcaOAugCg1OlcMKZfehawlzkk3cs1ElYM+9kTQCLj7DZKxxgfLlN6KTpBLz7LM8LJSJMpQH1XLzzIqHzKYpVN6Qtn3GpPxSJn5JpceCkcl1ITyw0zBEZMqLKlEcWcmQD/sqZIK5le1P9hdATCozJsnK3t+yHukOrhyYEPkjW4HRikJy9TSSuJTpUAedD2fSCGbjgq7Jxb10+C0Y2z8fdk/KQpJABWycpFkSFNa+NvDB1kL0f7hlAgl/zs/vAUoieT+P1O/gtbjGSDUxsqUYDksevBLQM1e4J1WViccpUw9LEbqsErWQY05S1oHCHG7uNjDrp4OsLKT+oF2Rs17aedQpB9qbkTy2vls+dsP4Us47GLt1vSDCOqrF32bRqBUAzjIE0MtRbisOE2zXud8edpX1bFOkJ9CFjUp75monsUsf+PEYsaC0Pkvh6GEtgWZwwB+TozPeTdUqI4EicIleFpwZSWkAkGnxYAhCkJJMSXz+O6DXaJFXQ05upWv/bVAV4+TxyzUPyN8CnoRO6fZkWtrpiFxw2xv9NV40OdTRToEaeIAmc3IxtyBV4HPBA0xceUGGBI8DjKz0UpwyaZgm5aE34HvI9YxcgiUiZckuskVaLpxk/tT4C2NIK+lwts5KhCPAo1mhC+AMkH/QRMp+oI9XGlpyepSD5OI/R3dMWu0/MhU57fhjz/PMOn X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(508600001)(86362001)(316002)(54906003)(6916009)(336012)(83380400001)(66574015)(6666004)(36756003)(7636003)(36860700001)(40460700003)(356005)(82960400001)(82310400005)(2616005)(107886003)(1076003)(2906002)(70206006)(5660300002)(70586007)(47076005)(8676002)(186003)(8936002)(4326008)(26005)(6266002); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2022 15:17:47.9371 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8aefa276-91aa-489c-293a-08da1bce6fd8 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT040.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR07MB5793 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 Mark the trylock family of spinlock functions with __rte_warn_unused_result. Acked-by: Bruce Richardson Signed-off-by: Mattias Rönnblom Acked-by: Morten Brørup --- lib/eal/include/generic/rte_spinlock.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h index 40fe49d5ad..73ed4bfbdc 100644 --- a/lib/eal/include/generic/rte_spinlock.h +++ b/lib/eal/include/generic/rte_spinlock.h @@ -97,6 +97,7 @@ rte_spinlock_unlock (rte_spinlock_t *sl) * @return * 1 if the lock is successfully taken; 0 otherwise. */ +__rte_warn_unused_result static inline int rte_spinlock_trylock (rte_spinlock_t *sl); @@ -174,6 +175,7 @@ rte_spinlock_unlock_tm(rte_spinlock_t *sl); * 1 if the hardware memory transaction is successfully started * or lock is successfully taken; 0 otherwise. */ +__rte_warn_unused_result static inline int rte_spinlock_trylock_tm(rte_spinlock_t *sl); @@ -243,6 +245,7 @@ static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr) * @return * 1 if the lock is successfully taken; 0 otherwise. */ +__rte_warn_unused_result static inline int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr) { int id = rte_gettid(); @@ -299,6 +302,7 @@ static inline void rte_spinlock_recursive_unlock_tm( * 1 if the hardware memory transaction is successfully started * or lock is successfully taken; 0 otherwise. */ +__rte_warn_unused_result static inline int rte_spinlock_recursive_trylock_tm( rte_spinlock_recursive_t *slr); From patchwork Mon Apr 11 15:15:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 109595 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F9B4A00BE; Mon, 11 Apr 2022 17:17:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9C80427EE; Mon, 11 Apr 2022 17:17:54 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2071.outbound.protection.outlook.com [40.107.20.71]) by mails.dpdk.org (Postfix) with ESMTP id 0FD76415D7; Mon, 11 Apr 2022 17:17:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K1RB+CU23sK38avwhNHCiger0cXBMY8SjyLik6iqZd7qxXdjTEKBv3TPkqnobFHrlCOIEb+6QSFb9bCtgBjkgNPayEBszSmFEVDMTpLfuqFwB8/I3UPy7bHOhOzgrC2taDr+F1rZTkfN+ZmLiHJ49QR15NbHxJBba2eLkIcxT2zqPUdMeAYS2ZK3gKDftFhZ3R3aA7OTc2F3tkkPoXh8fQ9jRwz4j+jIFdAKqEZlMCsWkYJZTs+ZqxvYeJvbj9tNRqBiECTXoVpciPCD6sQT1itPjCl9vHu7U81kDxXqRWF5Asv5zc0W/pWiG3xOKjXJpq2bbdEl4QN/RmivYh6cAA== 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=JQaN9C+BLxBXjwxOoA4nXOfmbS1e0RHOrAojiTZWJK8=; b=TDlwcv7G1lL24nxm2CPpQPpUxkgVeHglbEuU3Avo5f3w/siQD0cJGJapLe51aXX4e1WpEBWAcc5rolg/WB9ZXhO2tq9KkSBCW72VJEQoKx1Z+hRGZXK9q0RB7ULzQ89ASnJXtwP5f+/oyvAa1QJh7PK+B2y5xS938DeSKGffowwOSp5RAmQ+9EqeXzT/ZcyIfxnJJimYJSM7uu6lpgkbNuAfZE/RdR4m4KGzgo6AsJfxLjRSoToZeOINqye12HQcap7V4sRUiZ4lp7wkY1qTL3rbKu8uoZw7sO3jDHenoN3t2kHvwQuYWbsmsfqjQfOzxxdIciyfHGavN2yqHZYwfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=arm.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JQaN9C+BLxBXjwxOoA4nXOfmbS1e0RHOrAojiTZWJK8=; b=GnMUA4xlBPpFtlseNNFR2x2yx17OVu2noBB3GH8A6A3dul66C2q5Lnle+g4h8TUbjsRdW7VkE6Qe0KpcWoJh838N7ZjysbaqdgQa214bac2jaCb/uHxx0xyPOI8Xv2prfhpf6Q29T8104/S24PmXua6esW6Ke4AxYqkzi2oPIPE= Received: from AS9PR07CA0027.eurprd07.prod.outlook.com (2603:10a6:20b:46c::29) by AS8PR07MB7078.eurprd07.prod.outlook.com (2603:10a6:20b:253::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.17; Mon, 11 Apr 2022 15:17:52 +0000 Received: from VE1EUR02FT030.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::18) by AS9PR07CA0027.outlook.office365.com (2603:10a6:20b:46c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.17 via Frontend Transport; Mon, 11 Apr 2022 15:17:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by VE1EUR02FT030.mail.protection.outlook.com (10.152.12.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.5144.20 via Frontend Transport; Mon, 11 Apr 2022 15:17:52 +0000 Received: from ESESSMB505.ericsson.se (153.88.183.166) by ESESSMR503.ericsson.se (153.88.183.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.27; Mon, 11 Apr 2022 17:17:51 +0200 Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESSMB505.ericsson.se (153.88.183.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.27; Mon, 11 Apr 2022 17:17:51 +0200 Received: from seliiuapp00218.seli.gic.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.186) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Mon, 11 Apr 2022 17:17:50 +0200 Received: from localhost.localdomain (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliiuapp00218.seli.gic.ericsson.se (Postfix) with ESMTP id 71C3660160; Mon, 11 Apr 2022 17:17:51 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: Bruce Richardson , Thomas Monjalon , David Marchand , , , , Stephen Hemminger , =?utf-8?q?Mattias_R=C3=B6nn?= =?utf-8?q?blom?= , , , Min Hu Subject: [PATCH 3/3] examples/bond: fix invalid use of trylock Date: Mon, 11 Apr 2022 17:15:59 +0200 Message-ID: <20220411151559.164217-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411151559.164217-1-mattias.ronnblom@ericsson.com> References: <20220411151559.164217-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 231d55de-002b-4f9f-f932-08da1bce726e X-MS-TrafficTypeDiagnostic: AS8PR07MB7078: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: WPHlnyj/81Tq8TbUyzM3STnLRbENG5DrNMnzq2BtX+ZLTr0/y32HOhSC/fSIQ2d6667T1jTRQflunZmDO4/q/AEgAWicM4xzpppuUEO4xv0leTVHJFE71/UJKiUWj/rSLaFEIjrg9tmnns9Q4u6la0lhg7XLpSV7FknbvzmpkW9z3o6UTTd5rIH+/8C2/vWYaE7DXcPCUAslRIu+HR1gaCnOjvXyMiVdDYKuOnSTElDPhrHleCcQoxQidVmftbN2k26jaJnOvfHZtUQG9zXhdjAbLYy3Sbfpo0kDrczXFA0OVZnzdB32GjW3d+DHWjII4jTlCzJukPQk2Z3XIKpQlc9Vi/FUPbueLq0+Cl3gLn+CbSJ8pDuJE7DRXqqUVVcOxbYZsefnEfa7oag4LQ+VYOKAzsOZc8h+hjeCJVm/IU1wZhduJrk0hDxXa3jCIvY2mOa7O+F3eXDYt/akzQ+ilCqEJQ9NwX/dsd87fV8S6GVeZ7GNrDNmzmeN9MZy+eEZ/L9/9feqlPm5Sar/ShjQgu1q/CpY5/SOgDeJjYoxie2KtuhoUP5Br5Ieb4cXVxBa6wbnIxrSl/V/9esVVjJqod114pyDbd/O+V7xBODnH+IB9FCyO+8IcdJ2ZVhU8winM+3+JtWShgxPkRUdE+ssG0zbC6AgbwpR9fdLyLy472WsJ6vB98OegAqh0Rs9aGdolYOFiu2/c1T0BG3SZLLrlGSS7uDy76zK/U7CKPQ9mrU= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(508600001)(86362001)(316002)(6916009)(54906003)(66574015)(83380400001)(47076005)(36756003)(7636003)(36860700001)(40460700003)(82960400001)(356005)(1076003)(82310400005)(336012)(2616005)(6266002)(2906002)(70206006)(5660300002)(70586007)(7416002)(8676002)(186003)(8936002)(26005)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2022 15:17:52.2653 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 231d55de-002b-4f9f-f932-08da1bce726e X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT030.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7078 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 The conditional rte_spinlock_trylock() was used as if it is an unconditional lock operation in a number of places. Fixes: cc7e8ae84faa ("examples/bond: add example application for link bonding mode 6") Cc: michalx.k.jastrzebski@intel.com Cc: stable@dpdk.org Acked-by: Bruce Richardson Acked-by: Min Hu (Connor) Signed-off-by: Mattias Rönnblom --- examples/bond/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/bond/main.c b/examples/bond/main.c index 335bde5c8d..4efebb3902 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -373,7 +373,7 @@ static int lcore_main(__rte_unused void *arg1) bond_ip = BOND_IP_1 | (BOND_IP_2 << 8) | (BOND_IP_3 << 16) | (BOND_IP_4 << 24); - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); while (global_flag_stru_p->LcoreMainIsRunning) { rte_spinlock_unlock(&global_flag_stru_p->lock); @@ -456,7 +456,7 @@ static int lcore_main(__rte_unused void *arg1) if (is_free == 0) rte_pktmbuf_free(pkts[i]); } - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); } rte_spinlock_unlock(&global_flag_stru_p->lock); printf("BYE lcore_main\n"); @@ -571,7 +571,7 @@ static void cmd_start_parsed(__rte_unused void *parsed_result, { int worker_core_id = rte_lcore_id(); - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); if (global_flag_stru_p->LcoreMainIsRunning == 0) { if (rte_eal_get_lcore_state(global_flag_stru_p->LcoreMainCore) != WAIT) { @@ -591,7 +591,7 @@ static void cmd_start_parsed(__rte_unused void *parsed_result, if ((worker_core_id >= RTE_MAX_LCORE) || (worker_core_id == 0)) return; - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); global_flag_stru_p->LcoreMainIsRunning = 1; rte_spinlock_unlock(&global_flag_stru_p->lock); cmdline_printf(cl, @@ -659,7 +659,7 @@ static void cmd_stop_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); if (global_flag_stru_p->LcoreMainIsRunning == 0) { cmdline_printf(cl, "lcore_main not running on core:%d\n", @@ -700,7 +700,7 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); if (global_flag_stru_p->LcoreMainIsRunning == 0) { cmdline_printf(cl, "lcore_main not running on core:%d\n", @@ -762,7 +762,7 @@ static void cmd_show_parsed(__rte_unused void *parsed_result, printf("\n"); } - rte_spinlock_trylock(&global_flag_stru_p->lock); + rte_spinlock_lock(&global_flag_stru_p->lock); cmdline_printf(cl, "Active_slaves:%d " "packets received:Tot:%d Arp:%d IPv4:%d\n",