All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 1/7] ftrace: Clean up __seq_open_private() return check
Date: Wed, 05 Apr 2017 12:21:10 -0400	[thread overview]
Message-ID: <20170405162146.844566198@goodmis.org> (raw)
In-Reply-To: 20170405162109.825936532@goodmis.org

[-- Attachment #1: 0001-ftrace-Clean-up-__seq_open_private-return-check.patch --]
[-- Type: text/plain, Size: 1668 bytes --]

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The return status check of __seq_open_private() is rather strange:

	iter = __seq_open_private();
	if (iter) {
		/* do stuff */
	}

	return iter ? 0 : -ENOMEM;

It makes much more sense to do the return of failure right away:

	iter = __seq_open_private();
	if (!iter)
		return -ENOMEM;

	/* do stuff */

	return 0;

This clean up will make updates to this code a bit nicer.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 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 0556a202c055..527c4d3e8d7f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3355,12 +3355,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
@@ -3369,13 +3370,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;
 }
 
 /**
-- 
2.10.2

  reply	other threads:[~2017-04-05 16:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05 16:21 [for-next][PATCH 0/7] tracing: Updates to filter probes and early ftrace init Steven Rostedt
2017-04-05 16:21 ` Steven Rostedt [this message]
2017-04-05 16:21 ` [for-next][PATCH 2/7] ftrace: Assign iter->hash to filter or notrace hashes on seq read Steven Rostedt
2017-04-05 16:21 ` [for-next][PATCH 3/7] ftrace: Return NULL at end of t_start() instead of calling t_hash_start() Steven Rostedt
2017-04-05 16:21 ` [for-next][PATCH 4/7] ftrace: Update func_pos in t_start() when all functions are enabled Steven Rostedt
2017-04-05 16:21 ` [for-next][PATCH 5/7] ftrace: Create separate t_func_next() to simplify the function / hash logic Steven Rostedt
2017-04-05 16:21 ` [for-next][PATCH 6/7] ftrace: Have init/main.c call ftrace directly to free init memory Steven Rostedt
2017-04-05 16:21 ` [for-next][PATCH 7/7] tracing/kprobes: expose maxactive for kretprobe in kprobe_events Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170405162146.844566198@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.