Re: [PATCH 05/11] make red_pipe_item_init_full more typesafe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> > > I don't find this very readable, and imo there is not a huge gain in
> > > doing this over a cast... I'd just go with a cast + a static
> > > compile-time assert that RedCursorPipeItem has a 'base' RedPipeItem
> > > field at offset 0.
> > > 
> > 
> > static void cursor_pipe_item_free(RedPipeItem *base)
> > {
> >    spice_return_if_fail(base);
> > 
> >    verify(SPICE_OFFSETOF(RedCursorPipeItem, base) == 0);
> >    RedCursorPipeItem *pipe_item = (RedCursorPipeItem *) base;
> >    ...
> > 
> > (obviously for every cast)
> 
> I'd put it next to the structure definition and forget about it
> 
> typedef struct RedCursorPipeItem {
>     RedPipeItem base;
>     CursorItem *cursor_item;
> } RedCursorPipeItem;
> 
> verify(SPICE_OFFSETOF(RedCursorPipeItem, base) == 0);
> 
> Christophe
> 

You didn't understand the problem, this is not enough
as a refactory of this would require a complete code scan
as currently is (was?) needed, you have to check for every
cast.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]