public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: James Morris <jmorris@intercode.com.au>
Cc: Davide Libenzi <davidel@xmailserver.org>,
	Matthew Wilcox <willy@debian.org>,
	Patrick Mochel <mochel@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: kobjects, sysfs and the driver model make my head hurt
Date: Sun, 06 Jul 2003 13:15:12 -0400	[thread overview]
Message-ID: <3F085920.2040506@pobox.com> (raw)
In-Reply-To: <Mutt.LNX.4.44.0307070300180.930-100000@excalibur.intercode.com.au>

James Morris wrote:
> On Sun, 6 Jul 2003, Davide Libenzi wrote:
> 
> 
>>On Sun, 6 Jul 2003, Matthew Wilcox wrote:
>>
>>
>>>Why on earth does it return the value of its argument?
>>
>>Maybe for the same reason 'strcpy' returns 'dest'. It allows you to use
>>the function in a function parameter :
> 
> 
> It also makes calling code cleaner when copying refcounted objects:
> 
> e.g.
> 	new->foo = foo_get(old->foo);
> 	new->bar = bar_get(old->bar);
> 
> otherwise, you'd have to do:
> 
> 	foo_get(old->foo);
> 	new->foo = old->foo;
> 	bar_get(old->bar);
> 	new->bar = old->bar;

well...

	struct blah *foo_ref = foo;
	... not using foo_ref ...
	foo_get(foo_ref);
	... using foo_ref ...
	foo_put(foo_ref);

versus

	struct blah *foo_ref;
	... not using foo_ref ...
	foo_ref = foo_get(foo);
	... using foo_ref ...
	foo_put(foo_ref);

I suppose it's a matter of taste rather than necessity.

As a tangent, if kobject_get is so small now, why not just make it 
static inline to optimize this case?

	Jeff




  reply	other threads:[~2003-07-06 17:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-06 16:33 kobjects, sysfs and the driver model make my head hurt Matthew Wilcox
2003-07-06 16:42 ` Davide Libenzi
2003-07-06 17:03   ` James Morris
2003-07-06 17:15     ` Jeff Garzik [this message]
2003-07-07  7:05   ` Johan.Adolfsson
2003-07-06 16:46 ` Greg KH
2003-07-06 16:54   ` Jeff Garzik

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=3F085920.2040506@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=davidel@xmailserver.org \
    --cc=jmorris@intercode.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    --cc=willy@debian.org \
    /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