[vlc-devel] [PATCH] objects: get the vlc_object_t from vlc_object_internals using vlc_internals()

Rémi Denis-Courmont remi at remlab.net
Tue Jul 25 19:45:26 CEST 2017

Le tiistaina 25. heinäkuuta 2017, 19.22.19 EEST Steve Lhomme a écrit :
> On Tue, Jul 25, 2017 at 6:33 PM, Rémi Denis-Courmont <remi at remlab.net> 
> > Le tiistaina 25. heinäkuuta 2017, 18.06.32 EEST Steve Lhomme a écrit :
> >> So that's it coherent with the rest of the usages.
> > 
> > Not really. The other uses operate on an initialized object. Here, we are
> > creating and initializing the object.
> It's just about accessing the pointer.

Says who? I wrote those accessor macros, and that´s not how I conceived them 
nor how I think of them. Using accessors on unitialized objects makes no sense 
to me.

> It doesn't matter what is in the pointed data.

The current implementation of the macros is such that initialization does not 
matter. Likewise, it is such that this patch does not matter; it replaces one 
expression with an equivalent expression.

So nack.

> > flexible array in ISO C ensures that the two expressions are equivalent.
> > One uses byte offsets, and the other direct pointer arithmetic.
> If that was equivalent, this wouldn't fail:
> static_assert( sizeof(struct vlc_object_internals) !=
>              offsetof(struct vlc_object_internals, aligned_end),
>              "invalid align_end access");

It *is* equivalent, and that assertion *cannot* fail.

By definition of pointer arithmetic, pointer plus one equals the pointer plus 
the size of pointed type and by definition of flexible arrays, the offset of a 
flexible array within its contained structure is the size of the structure.

That was the whole point of appending aligned_end in the first place.


More information about the vlc-devel mailing list