Skip to content

Commit

Permalink
mm/slab.c: use __seq_open_private() instead of seq_open()
Browse files Browse the repository at this point in the history
Using __seq_open_private() removes boilerplate code from slabstats_open()

The resultant code is shorter and easier to follow.

This patch does not change any functionality.

Signed-off-by: Rob Jones <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Rob Jones authored and torvalds committed Oct 10, 2014
1 parent 703394c commit b208ce3
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -4178,19 +4178,15 @@ static const struct seq_operations slabstats_op = {

static int slabstats_open(struct inode *inode, struct file *file)
{
unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
int ret = -ENOMEM;
if (n) {
ret = seq_open(file, &slabstats_op);
if (!ret) {
struct seq_file *m = file->private_data;
*n = PAGE_SIZE / (2 * sizeof(unsigned long));
m->private = n;
n = NULL;
}
kfree(n);
}
return ret;
unsigned long *n;

n = __seq_open_private(file, &slabstats_op, PAGE_SIZE);
if (!n)
return -ENOMEM;

*n = PAGE_SIZE / (2 * sizeof(unsigned long));

return 0;
}

static const struct file_operations proc_slabstats_operations = {
Expand Down

0 comments on commit b208ce3

Please sign in to comment.