[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20150617151412.GA32502@chengyihe-ThinkCentre-M82>
Date: Wed, 17 Jun 2015 23:14:12 +0800
From: ChengYi He <chengyihetaipei@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] ftrace: refactor to improve readability
Return error code immediately after __seq_open_private returns NULL.
Signed-off-by: ChengYi He <chengyihetaipei@...il.com>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists