From d66a0520cb46fb4f86b070e5f1926f6e53f23b38 Mon Sep 17 00:00:00 2001 From: Rob Jones Date: Mon, 13 Oct 2014 15:54:14 -0700 Subject: ipc/util.c: use __seq_open_private() instead of seq_open() 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- ipc/util.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'ipc') diff --git a/ipc/util.c b/ipc/util.c index d73b7af581e2..88adc329888c 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) -- cgit v1.2.3-70-g09d2