diff options
author | Rob Jones <rob.jones@codethink.co.uk> | 2014-10-13 18:54:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-13 20:18:23 -0400 |
commit | d66a0520cb46fb4f86b070e5f1926f6e53f23b38 (patch) | |
tree | b7281faa4e9b6bffe7215d1bb875830e6ca64e99 /ipc/util.c | |
parent | bf77b94c99ad5df0d97a52522fc7a220c0bf44fe (diff) |
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>
Diffstat (limited to 'ipc/util.c')
-rw-r--r-- | ipc/util.c | 20 |
1 files changed, 4 insertions, 16 deletions
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 = { | |||
892 | 892 | ||
893 | static int sysvipc_proc_open(struct inode *inode, struct file *file) | 893 | static int sysvipc_proc_open(struct inode *inode, struct file *file) |
894 | { | 894 | { |
895 | int ret; | ||
896 | struct seq_file *seq; | ||
897 | struct ipc_proc_iter *iter; | 895 | struct ipc_proc_iter *iter; |
898 | 896 | ||
899 | ret = -ENOMEM; | 897 | iter = __seq_open_private(file, &sysvipc_proc_seqops, sizeof(*iter)); |
900 | iter = kmalloc(sizeof(*iter), GFP_KERNEL); | ||
901 | if (!iter) | 898 | if (!iter) |
902 | goto out; | 899 | return -ENOMEM; |
903 | |||
904 | ret = seq_open(file, &sysvipc_proc_seqops); | ||
905 | if (ret) { | ||
906 | kfree(iter); | ||
907 | goto out; | ||
908 | } | ||
909 | |||
910 | seq = file->private_data; | ||
911 | seq->private = iter; | ||
912 | 900 | ||
913 | iter->iface = PDE_DATA(inode); | 901 | iter->iface = PDE_DATA(inode); |
914 | iter->ns = get_ipc_ns(current->nsproxy->ipc_ns); | 902 | iter->ns = get_ipc_ns(current->nsproxy->ipc_ns); |
915 | out: | 903 | |
916 | return ret; | 904 | return 0; |
917 | } | 905 | } |
918 | 906 | ||
919 | static int sysvipc_proc_release(struct inode *inode, struct file *file) | 907 | static int sysvipc_proc_release(struct inode *inode, struct file *file) |