diff mbox series

[1/2] scripts/gdb: Cleanup error handling in list helpers

Message ID c1d3fd4db13d999a3ba57f5bbc1924862d824f61.1556881728.git.leonard.crestez@nxp.com (mailing list archive)
State Awaiting Upstream, archived
Headers show
Series gdb/scripts: Improve lx-clk-summary | expand

Commit Message

Leonard Crestez May 3, 2019, 11:19 a.m. UTC
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 <leonard.crestez@nxp.com>
---
 scripts/gdb/linux/lists.py | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Stephen Boyd May 3, 2019, 4:33 p.m. UTC | #1
Quoting Leonard Crestez (2019-05-03 04:19:31)
> 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

This should be done to other "type errors" in the gdb scripts too.

> 
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
> ---

Either way,

Reviewed-by: Stephen Boyd <sboyd@kernel.org>
diff mbox series

Patch

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