From: Rob Jones <rob.jones@codethink.co.uk>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, jbaron@akamai.com, cl@linux-foundation.org,
penberg@kernel.org, mpm@selenic.com, akpm@linux-foundation.org,
linux-kernel@codethink.co.uk, rob.jones@codethink.co.uk
Subject: [PATCH 1/4] ipc: Use __seq_open_private() instead of seq_open()
Date: Fri, 29 Aug 2014 17:06:37 +0100 [thread overview]
Message-ID: <1409328400-18212-2-git-send-email-rob.jones@codethink.co.uk> (raw)
In-Reply-To: <1409328400-18212-1-git-send-email-rob.jones@codethink.co.uk>
Using __seq_open_private() removes boilerplate code from
sysvipc_proc_open().
The resultant code is shorter and easier to follow.
However, please note that __seq_open_private() call kzalloc() rather than
kmalloc() which may affect timing due to the memory initialisation overhead.
Signed-off-by: Rob Jones <rob.jones@codethink.co.uk>
---
ipc/util.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/ipc/util.c b/ipc/util.c
index 2eb0d1e..98cb51d 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -892,28 +892,16 @@ static const struct seq_operations sysvipc_proc_seqops = {
static int sysvipc_proc_open(struct inode *inode, struct file *file)
{
- int ret;
- struct seq_file *seq;
struct ipc_proc_iter *iter;
- ret = -ENOMEM;
- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+ iter = __seq_open_private(file, &sysvipc_proc_seqops, sizeof(*iter));
if (!iter)
- goto out;
-
- ret = seq_open(file, &sysvipc_proc_seqops);
- if (ret) {
- kfree(iter);
- goto out;
- }
-
- seq = file->private_data;
- seq->private = iter;
+ return -ENOMEM;
iter->iface = PDE_DATA(inode);
iter->ns = get_ipc_ns(current->nsproxy->ipc_ns);
-out:
- return ret;
+
+ return 0;
}
static int sysvipc_proc_release(struct inode *inode, struct file *file)
--
1.7.10.4
next prev parent reply other threads:[~2014-08-29 16:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-29 16:06 [PATCH 0/4] Tidy up of modules using seq_open() Rob Jones
2014-08-29 16:06 ` Rob Jones [this message]
2014-08-29 16:06 ` [PATCH 2/4] mm: Use seq_open_private() instead of seq_open() Rob Jones
2014-08-29 16:06 ` [PATCH 3/4] mm: Use __seq_open_private() " Rob Jones
2014-08-29 16:24 ` Christoph Lameter
2014-08-29 16:06 ` [PATCH 4/4] lib: Use seq_open_private() " Rob Jones
2014-08-29 19:18 ` Jason Baron
2014-08-29 19:14 ` [PATCH 0/4] Tidy up of modules using seq_open() Andrew Morton
2014-09-01 12:47 ` Rob Jones
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=1409328400-18212-2-git-send-email-rob.jones@codethink.co.uk \
--to=rob.jones@codethink.co.uk \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=jbaron@akamai.com \
--cc=linux-kernel@codethink.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpm@selenic.com \
--cc=penberg@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).