Skip to contentSkip to conversation

fs/fscache/object-list.c: use __seq_open_private()

PATCH In review Rob Jones 2 participants 3 messages Sep 17, 2014 – Oct 14, 2014

lore
Share & tools
lore

Rob Jones

author
#0 lore raw

PATCH 1/1 fs/fscache/object-list.c: use __seq_open_private()

Reduce boilerplate code by using __seq_open_private() instead of seq_open() in fscache_objlist_open().

---

Note that sparse generates a warning on this file but it is outside the remit of this patch.

Note 2, it looks to me like the sparse warning may be a false positive.

 fs/fscache/object-list.c |   16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
fs/fscache/object-list.c +2 -14
index b5ebc2d..a1ca2f9 100644
@@ -380,26 +380,14 @@ no_config:
 static int fscache_objlist_open(struct inode *inode, struct file *file)
 {
 	struct fscache_objlist_data *data;
-	struct seq_file *m;
-	int ret;
 
-	ret = seq_open(file, &fscache_objlist_ops);
-	if (ret < 0)
-		return ret;
-
-	m = file->private_data;
-
-	/* buffer for key extraction */
-	data = kmalloc(sizeof(struct fscache_objlist_data), GFP_KERNEL);
-	if (!data) {
-		seq_release(inode, file);
+	data = __seq_open_private(file, &fscache_objlist_ops, sizeof(*data));
+	if (!data)
 		return -ENOMEM;
-	}
 
 	/* get the configuration key */
 	fscache_objlist_config(data);
 
-	m->private = data;
 	return 0;
 }
 
Signature · 1 line
1.7.10.4
author
#1 lore raw

I submitted the patch below on 17th September but have had no feedback.

It seems to me a worthwhile change (well, I wouldn't have written it otherwise) but does anybody else have any comments on it?

Quoted 48 lines · Rob Jones

Reduce boilerplate code by using __seq_open_private() instead of seq_open() in fscache_objlist_open().

---

Note that sparse generates a warning on this file but it is outside the remit of this patch.

Note 2, it looks to me like the sparse warning may be a false positive.

  fs/fscache/object-list.c |   16 ++--------------
  1 file changed, 2 insertions(+), 14 deletions(-)
fs/fscache/object-list.c +2 -14
index b5ebc2d..a1ca2f9 100644
@@ -380,26 +380,14 @@ no_config:
  static int fscache_objlist_open(struct inode *inode, struct file *file)
  {
  	struct fscache_objlist_data *data;
-	struct seq_file *m;
-	int ret;
 
-	ret = seq_open(file, &fscache_objlist_ops);
-	if (ret < 0)
-		return ret;
-
-	m = file->private_data;
-
-	/* buffer for key extraction */
-	data = kmalloc(sizeof(struct fscache_objlist_data), GFP_KERNEL);
-	if (!data) {
-		seq_release(inode, file);
+	data = __seq_open_private(file, &fscache_objlist_ops, sizeof(*data));
+	if (!data)
  		return -ENOMEM;
-	}
 
  	/* get the configuration key */
  	fscache_objlist_config(data);
 
-	m->private = data;
  	return 0;
  }
 
Signature · 4 lines
Rob Jones
Codethink Ltd
mailto:[email protected]
tel:+44 161 236 5575
#2 lore raw
Quoted 1 line · Rob Jones

I submitted the patch below on 17th September but have had no feedback.

It is now upstream.

David