diff options
author | Leonard Crestez <leonard.crestez@nxp.com> | 2019-05-14 18:46:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-14 22:52:52 -0400 |
commit | 66d5c7c60acfeb21d80ff03a349e3b6600caa117 (patch) | |
tree | 54742b858e7ab0a5b79e1d3340cbe6b90c2c2ef4 /scripts/gdb/linux/lists.py | |
parent | 988b2686159759401a4549d0fc30ff9a8758391a (diff) |
scripts/gdb: clean up error handling in list helpers
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 <leonard.crestez@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb/linux/lists.py')
-rw-r--r-- | scripts/gdb/linux/lists.py | 10 |
1 files 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 | |||
@@ -24,7 +24,7 @@ def list_for_each(head): | |||
24 | if head.type == list_head.get_type().pointer(): | 24 | if head.type == list_head.get_type().pointer(): |
25 | head = head.dereference() | 25 | head = head.dereference() |
26 | elif head.type != list_head.get_type(): | 26 | elif head.type != list_head.get_type(): |
27 | raise gdb.GdbError("Must be struct list_head not {}" | 27 | raise TypeError("Must be struct list_head not {}" |
28 | .format(head.type)) | 28 | .format(head.type)) |
29 | 29 | ||
30 | node = head['next'].dereference() | 30 | node = head['next'].dereference() |
@@ -35,9 +35,6 @@ def list_for_each(head): | |||
35 | 35 | ||
36 | def list_for_each_entry(head, gdbtype, member): | 36 | def list_for_each_entry(head, gdbtype, member): |
37 | for node in list_for_each(head): | 37 | for node in list_for_each(head): |
38 | if node.type != list_head.get_type().pointer(): | ||
39 | raise TypeError("Type {} found. Expected struct list_head *." | ||
40 | .format(node.type)) | ||
41 | yield utils.container_of(node, gdbtype, member) | 38 | yield utils.container_of(node, gdbtype, member) |
42 | 39 | ||
43 | 40 | ||
@@ -45,7 +42,7 @@ def hlist_for_each(head): | |||
45 | if head.type == hlist_head.get_type().pointer(): | 42 | if head.type == hlist_head.get_type().pointer(): |
46 | head = head.dereference() | 43 | head = head.dereference() |
47 | elif head.type != hlist_head.get_type(): | 44 | elif head.type != hlist_head.get_type(): |
48 | raise gdb.GdbError("Must be struct hlist_head not {}" | 45 | raise TypeError("Must be struct hlist_head not {}" |
49 | .format(head.type)) | 46 | .format(head.type)) |
50 | 47 | ||
51 | node = head['first'].dereference() | 48 | node = head['first'].dereference() |
@@ -56,9 +53,6 @@ def hlist_for_each(head): | |||
56 | 53 | ||
57 | def hlist_for_each_entry(head, gdbtype, member): | 54 | def hlist_for_each_entry(head, gdbtype, member): |
58 | for node in hlist_for_each(head): | 55 | for node in hlist_for_each(head): |
59 | if node.type != hlist_node.get_type().pointer(): | ||
60 | raise TypeError("Type {} found. Expected struct hlist_head *." | ||
61 | .format(node.type)) | ||
62 | yield utils.container_of(node, gdbtype, member) | 56 | yield utils.container_of(node, gdbtype, member) |
63 | 57 | ||
64 | 58 | ||