Re: [PATCH v8-RESEND 04/33] dyndbg: make ddebug_class_param union members same size

From: jim . cromie
Date: Tue May 21 2024 - 10:42:42 EST


On Tue, May 21, 2024 at 5:42 AM Łukasz Bartosik <ukaszb@xxxxxxxxxxxx> wrote:
>
> On Thu, May 16, 2024 at 7:44 PM Jim Cromie <jim.cromie@xxxxxxxxx> wrote:
> >
> > struct ddebug_class_param keeps a ref to the state-storage of the
> > param; make both class-types use the same unsigned long storage type.
> > ISTM this is simpler and safer.
>
> Why is it safer for members of a union to have the same size ?
>

Its mostly extra paranoia.
but if 2 users somehow get the class-type mixed up,
at least theres no alignment issue added into it.

And a problem like this would naturally happen (murphys law)
when the PARAM_REF macro is used, which uses/shares the existing storage,
so that existing code can use that storage.
For example, DRM uses PARAM_REF so it can continue to use __drm_debug
for a few spots in code that still examine the value during normal operations.

I'll reword the commit msg to say that more clearly (than this?)