Re: [PATCH v1 1/1] software node: Simplify swnode_register() a bit

From: Andy Shevchenko
Date: Fri Sep 13 2024 - 15:25:32 EST


On Fri, Sep 13, 2024 at 03:34:58PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Sep 13, 2024 at 02:05:23PM +0300, Andy Shevchenko wrote:

...

> > + struct kobject *kobj_parent = parent ? &parent->kobj : NULL;
>
> I despise ?: use just so much, EXCEPT for when it's used in something
> like this:

> > ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
> > - parent ? &parent->kobj : NULL,
> > - "%s", node->name);
> > + kobj_parent, "%s", node->name);
>
> Which really is the only valid way I'd put up with it :)

I see your point!

> So can you rewrite the change above to be just:
>
> struct kobject *kobj_parent = NULL;
>
> ...
>
> if (parent)
> kobj_parent = &parent->kobj;
>
> Which is much simpler to read, right?

Yeah, but the point of the patch seems to be diminished. Let's just not
continue with it for now. Maybe later it will make more sense.

Thank you for the review!

--
With Best Regards,
Andy Shevchenko