[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1410530978-29627-3-git-send-email-rob.jones@codethink.co.uk>
Date: Fri, 12 Sep 2014 15:09:38 +0100
From: Rob Jones <rob.jones@...ethink.co.uk>
To: linux-kernel@...r.kernel.org
Cc: akpm@...ux-foundation.org, linux-kernel@...ethink.co.uk,
rob.jones@...ethink.co.uk
Subject: [PATCH 2/2] fs: proc: use __seq_open_private()
Reduce boilerplate code by using __seq_open_private() instead of seq_open().
Signed-off-by: Rob Jones <rob.jones@...ethink.co.uk>
---
fs/proc/task_mmu.c | 42 ++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 442177b..c8e9045 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -235,19 +235,14 @@ static int do_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 void
@@ -1495,19 +1490,14 @@ static int numa_maps_open(struct inode *inode, struct file *file,
const struct seq_operations *ops)
{
struct numa_maps_private *priv;
- int ret = -ENOMEM;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
- if (priv) {
- priv->proc_maps.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->proc_maps.pid = proc_pid(inode);
+
+ return 0;
}
static int pid_numa_maps_open(struct inode *inode, struct file *file)
--
1.7.10.4
--
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