From: "Jesper Juhl" <jesper.juhl@gmail.com>
To: "Nathan Scott" <nathans@sgi.com>
Cc: linux-kernel@vger.kernel.org, xfs-masters@oss.sgi.com, xfs@oss.sgi.com
Subject: Re: [PATCH] XFS: remove pointless conditional testing 'nmp' vs NULL in fs/xfs/xfs_rtalloc.c::xfs_growfs_rt()
Date: Mon, 14 Aug 2006 09:25:53 +0200 [thread overview]
Message-ID: <9a8748490608140025w3257f315jcceccf05d200437f@mail.gmail.com> (raw)
In-Reply-To: <20060814110942.C2698880@wobbly.melbourne.sgi.com>
On 14/08/06, Nathan Scott <nathans@sgi.com> wrote:
> On Sun, Aug 13, 2006 at 12:16:50AM +0200, Jesper Juhl wrote:
> > In fs/xfs/xfs_rtalloc.c::xfs_growfs_rt() there's a completely useless
> > conditional at the error_exit label.
> > The 'if (nmp)' check is pointless and might as well be removed for two
> > reasons.
> >
> > 1) if 'nmp' is NULL then kmem_free() will end up calling kfree() with a NULL
> > argument - which in turn will just cause a return from kfree(). No harm
> > done.
>
> Thats valid.
>
> > 2) At the beginning of the function there's an assignment; '*nmp = *mp;' so
>
> Thats not. Theres no assignment at the start of the function;
> theres one inside the main body of the loop 20+ lines into it,
> and right after a mem alloc with flags requiring no failure.
> Later that local variable is freed then set to NULL inside the
> loop, before continuing the next iteration...
>
> Really this code would be better if reworked slightly to just
> allocate nmp once before entering the loop, and then free it
> once at the end... we wouldn't need a goto, just a few breaks
> in the loop and a conditional transaction cancel.
>
> > This patch gets rid of the pointless check.
>
> Hmm, seems like code churn that makes the code slightly less
> obvious, but thats just me... I'd prefer a tested patch that
> implements the above suggestion, to be honest. :)
>
Ok, I'll see what I can come up with.
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
next prev parent reply other threads:[~2006-08-14 7:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-12 22:16 Jesper Juhl
2006-08-14 1:09 ` Nathan Scott
2006-08-14 7:25 ` Jesper Juhl [this message]
2006-08-16 20:44 ` Jesper Juhl
2006-08-17 6:31 ` Nathan Scott
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=9a8748490608140025w3257f315jcceccf05d200437f@mail.gmail.com \
--to=jesper.juhl@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nathans@sgi.com \
--cc=xfs-masters@oss.sgi.com \
--cc=xfs@oss.sgi.com \
/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®