From: ebiederm@xmission.com (Eric W. Biederman)
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: Jesper Juhl <jj@chaosbits.net>,
linux-kernel@vger.kernel.org, Nick Piggin <npiggin@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] sysctl: remove impossible condition check
Date: Thu, 02 Jun 2011 06:40:13 -0700 [thread overview]
Message-ID: <m1y61kfj2a.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <BANLkTimnn8hAw7VqgbTTgheREox5DJBhcQ@mail.gmail.com> (Lucas De Marchi's message of "Wed, 1 Jun 2011 11:11:36 -0300")
Lucas De Marchi <lucas.demarchi@profusion.mobi> writes:
> [ CC'ing Al Viro ]
>
> On Wed, Jun 1, 2011 at 10:25 AM, Jesper Juhl <jj@chaosbits.net> wrote:
>> How about compacting it even further by getting rid of the 'len' variable
>> as well?
>> Like this:
>>
>> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
>> ---
>> proc_sysctl.c | 10 ++--------
>> 1 file changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
>> index f50133c..bd7f7af 100644
>> --- a/fs/proc/proc_sysctl.c
>> +++ b/fs/proc/proc_sysctl.c
>> @@ -49,17 +49,11 @@ out:
>>
>> 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 */
>>
>
>
> Looking again at the code, I'm wondering if this is not actually a
> bug. There might be entries with procname == NULL, meaning they are
> not mirrored in /proc. What seems wrong is the condition in the for().
> It should stop when all fields are 0 (meaning the end of the table)
> instead of stopping when procname is NULL.
It is not a bug. The condition was originally p->ctlname then
it became p->ctlname || p->procname and then finally I was able to
kill ctl_name.
What you see is a left over that didn't get removed.
This is also the second time in the last couple of weeks someone has
sent this patch.
There is some ongoing work to make sysctl scale better that with
any luck should be ready for 3.1. Decide which version of this
patch you like and please resend, and I will add this to my
sysctl tree.
Thank you,
Eric
next prev parent reply other threads:[~2011-06-02 13:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-01 13:15 Lucas De Marchi
2011-06-01 13:25 ` Jesper Juhl
2011-06-01 14:11 ` Lucas De Marchi
2011-06-02 13:40 ` Eric W. Biederman [this message]
2011-06-02 13:51 ` Lucas De Marchi
2011-06-02 16:00 ` Lucas De Marchi
[not found] ` <1307684165-14742-1-git-send-email-lucas.demarchi@profusion.mobi>
2011-06-10 7:56 ` Jesper Juhl
2011-06-12 6:02 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1y61kfj2a.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=hch@lst.de \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@profusion.mobi \
--cc=npiggin@kernel.dk \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®