[PATCH] ftrace: refactor to improve readability

From: ChengYi He
Date: Wed Jun 17 2015 - 11:14:27 EST


Return error code immediately after __seq_open_private returns NULL.

Signed-off-by: ChengYi He <chengyihetaipei@xxxxxxxxx>
---
kernel/trace/ftrace.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 02bece4..8e790b7 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3269,12 +3269,13 @@ ftrace_avail_open(struct inode *inode, struct file *file)
return -ENODEV;

iter = __seq_open_private(file, &show_ftrace_seq_ops, sizeof(*iter));
- if (iter) {
- iter->pg = ftrace_pages_start;
- iter->ops = &global_ops;
- }
+ if (!iter)
+ return -ENOMEM;

- return iter ? 0 : -ENOMEM;
+ iter->pg = ftrace_pages_start;
+ iter->ops = &global_ops;
+
+ return 0;
}

static int
@@ -3283,13 +3284,14 @@ ftrace_enabled_open(struct inode *inode, struct file *file)
struct ftrace_iterator *iter;

iter = __seq_open_private(file, &show_ftrace_seq_ops, sizeof(*iter));
- if (iter) {
- iter->pg = ftrace_pages_start;
- iter->flags = FTRACE_ITER_ENABLED;
- iter->ops = &global_ops;
- }
+ if (!iter)
+ return -ENOMEM;

- return iter ? 0 : -ENOMEM;
+ iter->pg = ftrace_pages_start;
+ iter->flags = FTRACE_ITER_ENABLED;
+ iter->ops = &global_ops;
+
+ return 0;
}

/**
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/