提交 36885d7b 编写于 作者: L Lucas De Marchi 提交者: Eric W. Biederman

sysctl: remove impossible condition check

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: NLucas De Marchi <lucas.demarchi@profusion.mobi>
Reviewed-by: NJesper Juhl <jj@chaosbits.net>
Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
上级 dcd6c922
...@@ -59,17 +59,11 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, ...@@ -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) static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name)
{ {
int len;
for ( ; p->procname; p++) { for ( ; p->procname; p++) {
if (strlen(p->procname) != name->len)
if (!p->procname)
continue;
len = strlen(p->procname);
if (len != name->len)
continue; continue;
if (memcmp(p->procname, name->name, len) != 0) if (memcmp(p->procname, name->name, name->len) != 0)
continue; continue;
/* I have a match */ /* I have a match */
...@@ -266,10 +260,6 @@ static int scan(struct ctl_table_header *head, ctl_table *table, ...@@ -266,10 +260,6 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
for (; table->procname; table++, (*pos)++) { for (; table->procname; table++, (*pos)++) {
int res; int res;
/* Can't do anything without a proc name */
if (!table->procname)
continue;
if (*pos < file->f_pos) if (*pos < file->f_pos)
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册