From: Greg KH <gregkh@linuxfoundation.org>
To: Wei Yang <weiyang@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kobject: avoid unnecessary assignment of kobj->parent
Date: Sat, 6 Jun 2015 13:22:30 +0900 [thread overview]
Message-ID: <20150606042230.GA15748@kroah.com> (raw)
In-Reply-To: <1433384030-16039-1-git-send-email-weiyang@linux.vnet.ibm.com>
On Thu, Jun 04, 2015 at 10:13:50AM +0800, Wei Yang wrote:
> kobj->parent is changed only when it is NULL originally.
>
> This patch moves the assignment in the "if" to avoid unnecessary assignment.
>
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> ---
> lib/kobject.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index 03d4ab3..37b10bb 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -216,9 +216,8 @@ static int kobject_add_internal(struct kobject *kobj)
> /* join kset if set, use it as parent if we do not already have one */
> if (kobj->kset) {
> if (!parent)
> - parent = kobject_get(&kobj->kset->kobj);
> + parent = kobj->parent = kobject_get(&kobj->kset->kobj);
> kobj_kset_join(kobj);
> - kobj->parent = parent;
What is this "fixing"? I hate multiple assignments on the same line,
it makes it harder to read and understand.
greg k-h
next prev parent reply other threads:[~2015-06-06 5:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-04 2:13 [PATCH] kobject: avoid unnecessary assignment of kobj->parent Wei Yang
2015-06-06 4:22 ` Greg KH [this message]
2015-06-08 2:26 ` Wei Yang
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=20150606042230.GA15748@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=weiyang@linux.vnet.ibm.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