Commit 772476df authored by Rob Jones's avatar Rob Jones Committed by Pablo Neira Ayuso

net/netfilter/x_tables.c: use __seq_open_private()

Reduce boilerplate code by using __seq_open_private() instead of seq_open()
in xt_match_open() and xt_target_open().
Signed-off-by: default avatarRob Jones <rob.jones@codethink.co.uk>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 84d7fce6
...@@ -1101,22 +1101,11 @@ static const struct seq_operations xt_match_seq_ops = { ...@@ -1101,22 +1101,11 @@ static const struct seq_operations xt_match_seq_ops = {
static int xt_match_open(struct inode *inode, struct file *file) static int xt_match_open(struct inode *inode, struct file *file)
{ {
struct seq_file *seq;
struct nf_mttg_trav *trav; struct nf_mttg_trav *trav;
int ret; trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav));
if (!trav)
trav = kmalloc(sizeof(*trav), GFP_KERNEL);
if (trav == NULL)
return -ENOMEM; return -ENOMEM;
ret = seq_open(file, &xt_match_seq_ops);
if (ret < 0) {
kfree(trav);
return ret;
}
seq = file->private_data;
seq->private = trav;
trav->nfproto = (unsigned long)PDE_DATA(inode); trav->nfproto = (unsigned long)PDE_DATA(inode);
return 0; return 0;
} }
...@@ -1165,22 +1154,11 @@ static const struct seq_operations xt_target_seq_ops = { ...@@ -1165,22 +1154,11 @@ static const struct seq_operations xt_target_seq_ops = {
static int xt_target_open(struct inode *inode, struct file *file) static int xt_target_open(struct inode *inode, struct file *file)
{ {
struct seq_file *seq;
struct nf_mttg_trav *trav; struct nf_mttg_trav *trav;
int ret; trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav));
if (!trav)
trav = kmalloc(sizeof(*trav), GFP_KERNEL);
if (trav == NULL)
return -ENOMEM; return -ENOMEM;
ret = seq_open(file, &xt_target_seq_ops);
if (ret < 0) {
kfree(trav);
return ret;
}
seq = file->private_data;
seq->private = trav;
trav->nfproto = (unsigned long)PDE_DATA(inode); trav->nfproto = (unsigned long)PDE_DATA(inode);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment