Skip to content

Commit

Permalink
sysctl: simplify find_in_table
Browse files Browse the repository at this point in the history
The if (!p->procname) check is useless because the loop condition
prevents it from happening.

Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
  • Loading branch information
luciang committed Dec 5, 2011
1 parent a8c4ce6 commit f616f00
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions fs/proc/proc_sysctl.c
Expand Up @@ -57,24 +57,11 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
return inode;
}

static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name)
static struct ctl_table *find_in_table(struct ctl_table *p, const char *name)
{
int len;
for ( ; p->procname; p++) {

if (!p->procname)
continue;

len = strlen(p->procname);
if (len != name->len)
continue;

if (memcmp(p->procname, name->name, len) != 0)
continue;

/* I have a match */
return p;
}
for ( ; p->procname; p++)
if (strcmp(p->procname, name) == 0)
return p;
return NULL;
}

Expand All @@ -92,7 +79,7 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
struct ctl_table_header *head = grab_header(dir);
struct ctl_table *table = PROC_I(dir)->sysctl_entry;
struct ctl_table_header *h = NULL;
struct qstr *name = &dentry->d_name;
const char *name = dentry->d_name.name;
struct ctl_table *p;
struct inode *inode;
struct dentry *err = ERR_PTR(-ENOENT);
Expand Down

0 comments on commit f616f00

Please sign in to comment.