lkml.org 
[lkml]   [2015]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kobject: avoid unnecessary assignment of kobj->parent
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


\
 
 \ /
  Last update: 2015-06-06 08:21    [W:0.047 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site