[Spice-devel] [spice] server: Make sure g_object_new receive the correct data
Frediano Ziglio
fziglio at redhat.com
Mon Jul 25 11:52:53 UTC 2016
>
> On 07/22/2016 08:39 PM, Francois Gouget wrote:
> > g_object_new is a variadic function which take property values.
> > As compiler cannot check if these property values are correct
> > make sure they are using casts.
> > This actully fix a crash in reds.c for 32 bit architectures.
> >
> > Based on a patch by Frediano Ziglio <fziglio at redhat.com>
> > Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
> > ---
> >
> > I ran into this crash so I thought I'd resubmit this patch so nobody
> > else has to dig for this patch. This version keeps just the part of
> > Frediano Ziglio's patch that seemed uncontroversial.
> >
> > server/reds.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/server/reds.c b/server/reds.c
> > index 6d625de..992cf03 100644
> > --- a/server/reds.c
> > +++ b/server/reds.c
> > @@ -4507,8 +4507,8 @@ static RedCharDeviceVDIPort
> > *red_char_device_vdi_port_new(RedsState *reds)
> > {
> > return g_object_new(RED_TYPE_CHAR_DEVICE_VDIPORT,
> > "spice-server", reds,
> > - "client-tokens-interval", REDS_TOKENS_TO_SEND,
> > - "self-tokens", REDS_NUM_INTERNAL_AGENT_MESSAGES,
> > + "client-tokens-interval",
> > (guint64)REDS_TOKENS_TO_SEND,
> > + "self-tokens",
> > (guint64)REDS_NUM_INTERNAL_AGENT_MESSAGES,
> > "opaque", reds,
> > NULL);
> > }
> >
>
> The patch is ok, but I think it would be better
> to do the cast in the define itself, or replace
> the define with a const (g)uint64_t variable
>
> Uri.
This would bound the constant to the property which does
not make much sense as the constant can be used for
different purposes. What if the same constant is used for
two properties with different types?
Frediano
More information about the Spice-devel
mailing list