From: Rob Jones <rob.jones@codethink.co.uk>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, linux-kernel@codethink.co.uk,
rob.jones@codethink.co.uk
Subject: [PATCH 1/2] fs: proc: use __seq_open_private()
Date: Fri, 12 Sep 2014 15:09:37 +0100 [thread overview]
Message-ID: <1410530978-29627-2-git-send-email-rob.jones@codethink.co.uk> (raw)
In-Reply-To: <1410530978-29627-1-git-send-email-rob.jones@codethink.co.uk>
Reduce boilerplate code by using __seq_open_private() instead of seq_open().
Signed-off-by: Rob Jones <rob.jones@codethink.co.uk>
---
fs/proc/task_nommu.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 678455d..b141050 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -269,20 +269,14 @@ static int maps_open(struct inode *inode, struct file *file,
const struct seq_operations *ops)
{
struct proc_maps_private *priv;
- int ret = -ENOMEM;
-
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
- if (priv) {
- priv->pid = proc_pid(inode);
- ret = seq_open(file, ops);
- if (!ret) {
- struct seq_file *m = file->private_data;
- m->private = priv;
- } else {
- kfree(priv);
- }
- }
- return ret;
+
+ priv = __seq_open_private(file, ops, sizeof(*priv));
+ if (!priv)
+ return -ENOMEM;
+
+ priv->pid = proc_pid(inode);
+
+ return 0;
}
static int pid_maps_open(struct inode *inode, struct file *file)
--
1.7.10.4
next prev parent reply other threads:[~2014-09-12 14:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 14:09 [PATCH 0/2] fs: proc: use seq_open_private() Rob Jones
2014-09-12 14:09 ` Rob Jones [this message]
2014-09-12 21:54 ` [PATCH 1/2] fs: proc: use __seq_open_private() Andrew Morton
2014-09-15 13:42 ` Rob Jones
2014-09-29 16:02 ` Rob Jones
2014-09-12 14:09 ` [PATCH 2/2] " Rob Jones
2014-09-12 21:50 ` [PATCH 0/2] fs: proc: use seq_open_private() Andrew Morton
2014-09-15 7:21 ` Rob Jones
2014-09-15 7:27 ` Andrew Morton
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=1410530978-29627-2-git-send-email-rob.jones@codethink.co.uk \
--to=rob.jones@codethink.co.uk \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@codethink.co.uk \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).