Skip to content

Commit

Permalink
sysctl: remove impossible condition check
Browse files Browse the repository at this point in the history
Remove checks for conditions that will never happen. If procname is NULL
the loop would already had bailed out, so there's no need to check it
again.

At the same time this also compacts the function find_in_table() by
refactoring it to be easier to read.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Reviewed-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
  • Loading branch information
Lucas De Marchi authored and Eric W. Biederman committed Jan 25, 2012
1 parent dcd6c92 commit 36885d7
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,11 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,

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

if (!p->procname)
continue;

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

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

/* I have a match */
Expand Down Expand Up @@ -266,10 +260,6 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
for (; table->procname; table++, (*pos)++) {
int res;

/* Can't do anything without a proc name */
if (!table->procname)
continue;

if (*pos < file->f_pos)
continue;

Expand Down

0 comments on commit 36885d7

Please sign in to comment.