[Spice-devel] [PATCH spice-server] spicevmc: Check correctly rcc argument
Christophe Fergeau
cfergeau at redhat.com
Fri Jan 27 10:32:24 UTC 2017
On Thu, Jan 26, 2017 at 10:41:24AM -0500, Frediano Ziglio wrote:
> >
> > Do not check rcc after being use but before.
> >
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > ---
> > server/spicevmc.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/server/spicevmc.c b/server/spicevmc.c
> > index 064910e..df776f4 100644
> > --- a/server/spicevmc.c
> > +++ b/server/spicevmc.c
> > @@ -450,12 +450,11 @@ static void
> > spicevmc_red_channel_client_on_disconnect(RedChannelClient *rcc)
> > {
> > RedVmcChannel *channel;
> > SpiceCharDeviceInterface *sif;
> > - RedClient *client = red_channel_client_get_client(rcc);
> > + RedClient *client;
> >
> > - if (!rcc) {
> > - return;
> > - }
> > + g_return_if_fail(rcc != NULL);
> >
> > + client = red_channel_client_get_client(rcc);
g_return_if_fail() seems fine to me so that we get a log if something we
don't expect happens. This could even be
g_return_if_fail(RED_IS_CHANNEL_CLIENT(rcc));
No checks would indeed be better than the current if (!rcc) if this is
not supposed to happen.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170127/f19fee13/attachment.sig>
More information about the Spice-devel
mailing list