lkml.org 
[lkml]   [2022]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate
Hi Rafael,

On Mon, Oct 03, 2022 at 01:54:37PM +0200, Rafael J. Wysocki wrote:
> > I ask as I just went through a large refactoring of the kobject layer to
> > mark many things const * and I find it a bit "sad" that functions like
> > this:
> > static inline struct device *kobj_to_dev(const struct kobject *kobj)
> > {
> > return container_of(kobj, struct device, kobj);
> > }
> > have the ability to take a read-only pointer and spit out a writable one
> > thanks to the pointer math in container_of() with no one being the
> > wiser.
>
> Well, is this really a problem?
>
> After all, if an immutable structure is embedded in another one, that
> doesn't automatically imply that the containing structure has to be
> immutable too. Hence, a const pointer to the inner structure doesn't
> automatically yield a const pointer to the outer one.

I think in that case it'd be better, to at least make an informed decision
on that instead of just dropping the const qualifier.

--
Regards,

Sakari Ailus

\
 
 \ /
  Last update: 2022-10-03 14:01    [W:0.121 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site