Skip to content

Commit

Permalink
scripts/gdb: clean up error handling in list helpers
Browse files Browse the repository at this point in the history
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

Link: http://lkml.kernel.org/r/c1d3fd4db13d999a3ba57f5bbc1924862d824f61.1556881728.git.leonard.crestez@nxp.com
Signed-off-by: Leonard Crestez <[email protected]>
Reviewed-by: Stephen Boyd <[email protected]>
Cc: Jan Kiszka <[email protected]>
Cc: Jason Wessel <[email protected]>
Cc: Kieran Bingham <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
cdleonard authored and torvalds committed May 15, 2019
1 parent 988b268 commit 66d5c7c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions scripts/gdb/linux/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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()
Expand All @@ -35,17 +35,14 @@ def list_for_each(head):

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()
Expand All @@ -56,9 +53,6 @@ def hlist_for_each(head):

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)


Expand Down

0 comments on commit 66d5c7c

Please sign in to comment.