lkml.org 
[lkml]   [2011]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH] sysctl: remove impossible condition check
    On Wed, 1 Jun 2011, Lucas De Marchi wrote:

    > Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
    > ---
    > fs/proc/proc_sysctl.c | 5 +----
    > 1 files changed, 1 insertions(+), 4 deletions(-)
    >
    > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
    > index 2e5d3ec..98e82d4 100644
    > --- a/fs/proc/proc_sysctl.c
    > +++ b/fs/proc/proc_sysctl.c
    > @@ -52,11 +52,8 @@ 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)
    > continue;

    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 */

    --
    Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
    Don't top-post http://www.catb.org/jargon/html/T/top-post.html
    Plain text mails only, please.



    \
     
     \ /
      Last update: 2011-06-01 15:37    [W:0.038 / U:0.040 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site