[PATCH V3 01/17] kallsyms: Simplify update_iter_mod()
From: Adrian Hunter
Date: Tue May 22 2018 - 06:01:58 EST
The logic in update_iter_mod() is overcomplicated and gets worse every time
another get_ksymbol_* function is added.
In preparation for adding another get_ksymbol_* function, simplify logic in
update_iter_mod().
Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
---
kernel/kallsyms.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index a23e21ada81b..eda4b0222dab 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -510,23 +510,15 @@ static int update_iter_mod(struct kallsym_iter *iter, loff_t pos)
{
iter->pos = pos;
- if (iter->pos_ftrace_mod_end > 0 &&
- iter->pos_ftrace_mod_end < iter->pos)
- return get_ksymbol_bpf(iter);
-
- if (iter->pos_mod_end > 0 &&
- iter->pos_mod_end < iter->pos) {
- if (!get_ksymbol_ftrace_mod(iter))
- return get_ksymbol_bpf(iter);
+ if ((!iter->pos_mod_end || iter->pos_mod_end > pos) &&
+ get_ksymbol_mod(iter))
return 1;
- }
- if (!get_ksymbol_mod(iter)) {
- if (!get_ksymbol_ftrace_mod(iter))
- return get_ksymbol_bpf(iter);
- }
+ if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) &&
+ get_ksymbol_ftrace_mod(iter))
+ return 1;
- return 1;
+ return get_ksymbol_bpf(iter);
}
/* Returns false if pos at or past end of file. */
--
1.9.1