From patchwork Fri May 3 11:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10928257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D16DD1395 for ; Fri, 3 May 2019 11:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C217A27D29 for ; Fri, 3 May 2019 11:19:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B303A28390; Fri, 3 May 2019 11:19:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FEAE27D29 for ; Fri, 3 May 2019 11:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbfECLTs (ORCPT ); Fri, 3 May 2019 07:19:48 -0400 Received: from mail-eopbgr00082.outbound.protection.outlook.com ([40.107.0.82]:40769 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727153AbfECLTs (ORCPT ); Fri, 3 May 2019 07:19:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HxMPa5mcyYpaJZoYrtdn9sDzSXY9ZtnHJbTos7wWymw=; b=hD1F31YLYYCDJW3TEP1v+xqDNH40ev163j81fWHFPLuvYeiAB8iLP7gd7GlbkF4pu/qP5P9bYmATjleRypBDoIdsdHqGgfAQcbVoA7ql62WG9wsF8UTefBOUJFRKOqi7SFECMwAw9uebPH1PUYuSc1sxkXaBVaHXxlq4Mmpcx7A= Received: from AM0PR04MB6434.eurprd04.prod.outlook.com (20.179.252.215) by AM0PR04MB5859.eurprd04.prod.outlook.com (20.178.202.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.11; Fri, 3 May 2019 11:19:32 +0000 Received: from AM0PR04MB6434.eurprd04.prod.outlook.com ([fe80::19be:75a:9fe:7cec]) by AM0PR04MB6434.eurprd04.prod.outlook.com ([fe80::19be:75a:9fe:7cec%7]) with mapi id 15.20.1856.008; Fri, 3 May 2019 11:19:32 +0000 From: Leonard Crestez To: Stephen Boyd , Kieran Bingham , Jan Kiszka CC: Andrew Morton , Michael Turquette , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH 1/2] scripts/gdb: Cleanup error handling in list helpers Thread-Topic: [PATCH 1/2] scripts/gdb: Cleanup error handling in list helpers Thread-Index: AQHVAaIUVmCD1Tl5NEapbpBu30VdQQ== Date: Fri, 3 May 2019 11:19:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [89.37.124.34] x-mailer: git-send-email 2.17.1 x-clientproxiedby: VE1PR08CA0027.eurprd08.prod.outlook.com (2603:10a6:803:104::40) To AM0PR04MB6434.eurprd04.prod.outlook.com (2603:10a6:208:16c::23) authentication-results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4e0a6053-7668-4592-4616-08d6cfb936b8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:AM0PR04MB5859; x-ms-traffictypediagnostic: AM0PR04MB5859: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0026334A56 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(136003)(376002)(366004)(346002)(39860400002)(396003)(189003)(199004)(478600001)(256004)(66066001)(14454004)(6436002)(386003)(11346002)(446003)(66946007)(6512007)(2616005)(110136005)(316002)(476003)(6486002)(8676002)(66476007)(66556008)(64756008)(66446008)(99286004)(53936002)(3846002)(81156014)(81166006)(54906003)(118296001)(36756003)(6116002)(68736007)(8936002)(50226002)(44832011)(73956011)(2906002)(486006)(305945005)(76176011)(52116002)(4326008)(102836004)(6506007)(25786009)(5660300002)(186003)(26005)(7736002)(86362001)(71200400001)(71190400001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5859;H:AM0PR04MB6434.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: vMM7cP3o7tnaHo5j9IJXNho6qG1LlRjcUctAnah1jqj+XJ1KkRV7dEBMeXEbZQAtrL/aNg1o06J5i35NENwcEMtfcqq2VzpES8aLVMA/XH5JBBc7Xu7IXWmyvcFZcleyObrkR/0jM0URpYzqnByci6Kmin9Zep5PhoPXVj75BFU6zC0afimO/b/xh/EF54wXMaZgIknoE9bjyWYlvAamBpdEU8Opx49SMqclc3YoK6PSpvfqHOSwuXVtfFJQ/M0wWSZE//wd+zCF2zBAI4mATDskZkY+uJsyYjsY9CkY3MIAxc0Tc+KA4oB87fkYahNfw/6NB70ayQaoCoDjxJK4L1TnHD2de/shgpOSfltBjoVGsWQGAzOU5g2xPCXjay+Qtvw6lkrgWsXXPsxMocAOXEo3Aj3Utvo2ZR+CQpmm2no= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e0a6053-7668-4592-4616-08d6cfb936b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2019 11:19:31.5858 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5859 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP An incorrect argument to list_for_each is an internal error in gdb scripts so a TypeError should be raised. The gdb.GdbError exception type is intended for user errors such as incorrect invocation. Drop the type assertion in list_for_each_entry because list_for_each isn't going to suddenly yield something else. Applies to both list and hlist Signed-off-by: Leonard Crestez Reviewed-by: Stephen Boyd --- scripts/gdb/linux/lists.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py index 55356b66f8ea..c487ddf09d38 100644 --- a/scripts/gdb/linux/lists.py +++ b/scripts/gdb/linux/lists.py @@ -22,45 +22,39 @@ hlist_node = utils.CachedType("struct hlist_node") def list_for_each(head): if head.type == list_head.get_type().pointer(): head = head.dereference() elif head.type != list_head.get_type(): - raise gdb.GdbError("Must be struct list_head not {}" + raise TypeError("Must be struct list_head not {}" .format(head.type)) node = head['next'].dereference() while node.address != head.address: yield node.address node = node['next'].dereference() def list_for_each_entry(head, gdbtype, member): for node in list_for_each(head): - if node.type != list_head.get_type().pointer(): - raise TypeError("Type {} found. Expected struct list_head *." - .format(node.type)) yield utils.container_of(node, gdbtype, member) def hlist_for_each(head): if head.type == hlist_head.get_type().pointer(): head = head.dereference() elif head.type != hlist_head.get_type(): - raise gdb.GdbError("Must be struct hlist_head not {}" + raise TypeError("Must be struct hlist_head not {}" .format(head.type)) node = head['first'].dereference() while node.address: yield node.address node = node['next'].dereference() def hlist_for_each_entry(head, gdbtype, member): for node in hlist_for_each(head): - if node.type != hlist_node.get_type().pointer(): - raise TypeError("Type {} found. Expected struct hlist_head *." - .format(node.type)) yield utils.container_of(node, gdbtype, member) def list_check(head): nb = 0