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 <rob.jones@codethink.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
bf77b94c99
commit
d66a0520cb
1 changed files with 4 additions and 16 deletions
20
ipc/util.c
20
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)
|
static int sysvipc_proc_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct seq_file *seq;
|
|
||||||
struct ipc_proc_iter *iter;
|
struct ipc_proc_iter *iter;
|
||||||
|
|
||||||
ret = -ENOMEM;
|
iter = __seq_open_private(file, &sysvipc_proc_seqops, sizeof(*iter));
|
||||||
iter = kmalloc(sizeof(*iter), GFP_KERNEL);
|
|
||||||
if (!iter)
|
if (!iter)
|
||||||
goto out;
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = seq_open(file, &sysvipc_proc_seqops);
|
|
||||||
if (ret) {
|
|
||||||
kfree(iter);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
seq = file->private_data;
|
|
||||||
seq->private = iter;
|
|
||||||
|
|
||||||
iter->iface = PDE_DATA(inode);
|
iter->iface = PDE_DATA(inode);
|
||||||
iter->ns = get_ipc_ns(current->nsproxy->ipc_ns);
|
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)
|
static int sysvipc_proc_release(struct inode *inode, struct file *file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue