[Spice-devel] [PATCH 05/11] make red_pipe_item_init_full more typesafe

Christophe Fergeau cfergeau at redhat.com
Mon May 23 15:50:25 UTC 2016


On Mon, May 23, 2016 at 07:54:03AM -0400, Frediano Ziglio wrote:
> Other part. You can find code where the parent is NOT the first
> field (for different reasons), I did some improvements on this.
> You can also find places were a class is "inherited" just to
> reuse some feature, so it's really likely when this class will
> evolve you can have this field replaced by something else or
> moved (for instance if you have a more strong parent class).

I would not expect the refcounting behaviour to move away from the base
class fwiw.


> Unfortunately this is the way RedPipeItem and other classes are
> used. For these cases I much more prefer having to add a possible
> ".base" wherever will be needed than spending hours of
> debugging (as I did) trying to figure it out which part of code
> is writing the field "xxxx" without using the "xxxx" name or
> even the "Yyyy" structure which contains "xxxx".

Ok, I understand your goal, however the way it's done in this patch is
that you get your static checks, but the fact that a RedCursorItem "is
a" RedPipeItem because of inheritance is totally muddied by some
construct one has to parse and understand first while reading the code.
If you make this 'cursor_item = SPICE_UPCAST(RedCursorItem, pipe_item)',
feel free to do the checking you want in the macro, but I don't want
these checks to make the code much harder to read.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160523/10ccff36/attachment.sig>


More information about the Spice-devel mailing list