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

2019-05-03 Thread Stephen Boyd
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 
> ---

Either way,

Reviewed-by: Stephen Boyd 



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

2019-05-03 Thread Leonard Crestez
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 
---
 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
-- 
2.17.1