mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Tejun Heo" <htejun@gmail.com>
Cc: "Gabriel C" <nix.or.die@googlemail.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Christoph Lameter" <clameter@sgi.com>,
	gregkh@suse.de, miles.lane@gmail.com
Subject: Re: [PATCH] sysfs: kill an extra put in sysfs_create_link() failure path
Date: Wed, 18 Jul 2007 21:36:37 +0530	[thread overview]
Message-ID: <a781481a0707180906w38b151faqd7077ee3da21aff3@mail.gmail.com> (raw)
In-Reply-To: <469E352A.90909@gmail.com>

On 7/18/07, Tejun Heo <htejun@gmail.com> wrote:
> Satyam Sharma wrote:
> >> Well, I dunno.  Probably my taste just sucks.  Please feel free to
> >> submit patches and/or suggest better ideas.
> >
> > OK, for example:
> >
> > sysfs_find_dirent() -- to check for -EEXIST -- should be called
> > *before* we create the new dentry for the to-be-created symlink
> > in the first place. [ It's weird to grab a reference on the target
> > for ourselves (and in fact even allocate the new dirent for the
> > to-be-created symlink) and /then/ check for erroneous usage,
> > and then go about undoing all that we should never have done
> > at all. ] So this test could, and should, be made earlier, IMHO.
>
> Locking.

Well s/sysfs_find_dirent/sysfs_get_dirent/ then. And then simply put
down the reference later.

> Otherwise, why would the code look like that in the first place?


> > And some similar others ... so attached (sorry, Gmail web
> > interface) please find an attempt to make sysfs_create_link look
> > a trifle more like what it should look like, IMHO. The code cleanup
> > also leads to fewer LOC, smaller kernel image (lesser by 308 bytes),
> > and even speeding up the no-error common case of this function,
> > apart from the obvious readability benefits ... it's diffed on _top_ of
> > your bugfix here, but not the other patch. [ Compile-tested only. ]
>
> Compounded if-else vs. flattened if () with common error path is pretty
> much matter of being accustomed to.  I prefer the latter because it
> scales better (less nesting and less need for extra intelligence as
> error case grows).  As I'm already used to it, it's also easier on my
> eyes.

Umm, I don't see any compounded if-else that I added that wasn't
there already ... if any are, they only make the code clearly obvious
as to what it's doing in the first place. And we've still got a common
error path. Just that the error paths do not *need* to share any other
code than the simple "return error;" precisely because it's been
cleaned up. The existing code was just horrible, IMHO.

> So, unless you have more to offer, I'm not really sure whether
> the patch improves the situation noticeably.

Readability, fewer LOC, 308 lesser bytes in kernel image and
faster for the common case -- not good enough for you?! Oh, well.

Satyam

  reply	other threads:[~2007-07-18 16:06 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-14 12:18 Oops while modprobing phy fixed module Gabriel C
2007-07-14 12:44 ` Gabriel C
2007-07-15  5:39 ` Satyam Sharma
2007-07-15 17:42   ` Gabriel C
2007-07-15 20:32     ` Gabriel C
2007-07-15 21:14     ` Satyam Sharma
2007-07-15 22:19       ` Gabriel C
2007-07-16 12:17         ` Gabriel C
2007-07-16 15:19           ` Satyam Sharma
2007-07-16 15:41             ` Gabriel C
2007-07-16 16:18               ` Gabriel C
2007-07-16 16:54               ` Gabriel C
2007-07-16 18:23             ` Tejun Heo
2007-07-16 18:32               ` Gabriel C
2007-07-16 19:11                 ` Gabriel C
2007-07-16 19:13                   ` Gabriel C
2007-07-18  5:51                     ` Tejun Heo
2007-07-23 19:53                       ` Christoph Lameter
2007-07-24  6:35                         ` Tejun Heo
2007-07-18  7:14                     ` [PATCH] sysfs: kill an extra put in sysfs_create_link() failure path Tejun Heo
2007-07-18  7:38                       ` [PATCH] sysfs: cosmetic clean up on node creation failure paths Tejun Heo
2007-07-18 11:40                         ` Cornelia Huck
2007-07-18 11:16                       ` [PATCH] sysfs: kill an extra put in sysfs_create_link() failure path Cornelia Huck
2007-07-18 14:29                       ` Miles Lane
2007-07-18 14:48                       ` Satyam Sharma
2007-07-18 14:57                         ` Tejun Heo
2007-07-18 15:16                           ` Satyam Sharma
2007-07-18 15:30                             ` Satyam Sharma
2007-07-18 15:53                               ` Tejun Heo
2007-07-18 16:08                                 ` Satyam Sharma
2007-07-18 16:20                               ` Tejun Heo
2007-07-18 15:43                             ` Tejun Heo
2007-07-18 16:06                               ` Satyam Sharma [this message]
2007-07-18 16:30                                 ` Tejun Heo
2007-07-18 16:36                                   ` Satyam Sharma
2007-07-18 16:41                                   ` Tejun Heo
2007-07-18 16:49                                     ` Satyam Sharma
2007-07-18 16:59                                       ` Miles Lane
2007-07-23 19:52             ` Oops while modprobing phy fixed module Christoph Lameter
2007-07-16 17:43     ` Vitaly Bordug

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=a781481a0707180906w38b151faqd7077ee3da21aff3@mail.gmail.com \
    --to=satyam.sharma@gmail.com \
    --cc=clameter@sgi.com \
    --cc=gregkh@suse.de \
    --cc=htejun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miles.lane@gmail.com \
    --cc=nix.or.die@googlemail.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®