[Spice-devel] [spice-gtk] channel: Move local variables to inner block

Christophe Fergeau cfergeau at redhat.com
Fri Feb 17 10:22:28 UTC 2017


On Thu, Feb 16, 2017 at 04:36:35PM +0100, Pavel Grunt wrote:
> On Thu, 2017-02-16 at 16:13 +0100, Christophe Fergeau wrote:
> > Less things to keep track of when taking a quick look at the code
> > flow
> > of the spice_channel_load_ca() method.
> > 
> > Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> > ---
> >  src/spice-channel.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/spice-channel.c b/src/spice-channel.c
> > index 6556db3..b60b284 100644
> > --- a/src/spice-channel.c
> > +++ b/src/spice-channel.c
> > @@ -2364,10 +2364,6 @@ static gboolean
> > spice_channel_delayed_unref(gpointer data)
> >  static int spice_channel_load_ca(SpiceChannel *channel)
> >  {
> >      SpiceChannelPrivate *c = channel->priv;
> > -    STACK_OF(X509_INFO) *inf;
> > -    X509_INFO *itmp;
> > -    X509_STORE *store;
> > -    BIO *in;
> >      int i, count = 0;
> >      guint8 *ca;
> >      guint size;
> > @@ -2382,6 +2378,11 @@ static int spice_channel_load_ca(SpiceChannel
> > *channel)
> >      CHANNEL_DEBUG(channel, "Load CA, file: %s, data: %p", ca_file,
> > ca);
> >  
> >      if (ca != NULL) {
> > +        STACK_OF(X509_INFO) *inf;
> > +        X509_INFO *itmp;
> should go to the for block

Right, moved.

> 
> > +        X509_STORE *store;
> also used in a different block

I think it's better not to repeat the SSL_CTX_get_cert_store() for each
loop iteration.

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/20170217/77229c3a/attachment.sig>


More information about the Spice-devel mailing list