Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532AbbFDCOx (ORCPT ); Wed, 3 Jun 2015 22:14:53 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:58299 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbbFDCOr (ORCPT ); Wed, 3 Jun 2015 22:14:47 -0400 From: Wei Yang To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH] kobject: avoid unnecessary assignment of kobj->parent Date: Thu, 4 Jun 2015 10:13:50 +0800 Message-Id: <1433384030-16039-1-git-send-email-weiyang@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15060402-0025-0000-0000-0000019C3D1A Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1048 Lines: 32 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; } pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", -- 1.7.9.5 -- 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/