Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751317AbbFFF67 (ORCPT ); Sat, 6 Jun 2015 01:58:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52877 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbbFFF6w (ORCPT ); Sat, 6 Jun 2015 01:58:52 -0400 Date: Sat, 6 Jun 2015 13:22:30 +0900 From: Greg KH To: Wei Yang Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] kobject: avoid unnecessary assignment of kobj->parent Message-ID: <20150606042230.GA15748@kroah.com> References: <1433384030-16039-1-git-send-email-weiyang@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433384030-16039-1-git-send-email-weiyang@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1189 Lines: 32 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 > --- > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/