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

Christophe Fergeau cfergeau at redhat.com
Mon May 23 10:19:38 UTC 2016


On Mon, May 23, 2016 at 05:57:52AM -0400, Frediano Ziglio wrote:
> 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.

You did not explicitly state the problem either ;) I'm guessing that
you want to get a compile-time error in every places where there is a
cast from child class to base class (or the opposite)?

Personnally I'd consider that once you have one class inheriting from
another, then the parent instance has to be the first field in the child
instance struct, and that if you change that, you should expect quite
some pain (ie need to grep for both type names and check each use).
Since I don't consider changing the class hierarchy to be something
we'll do often, especially in the PipeItem case, this is why I'd just go
with casts and at most this static check near the struct definition.

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/5f1f4396/attachment.sig>


More information about the Spice-devel mailing list