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

Pavel Grunt pgrunt at redhat.com
Fri Feb 17 10:35:07 UTC 2017


On Fri, 2017-02-17 at 11:22 +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>
Acked-by: Pavel Grunt <pgrunt 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..af67931 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,12 +2378,17 @@ 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_STORE *store;
> +        BIO *in;
> +
>          store = SSL_CTX_get_cert_store(c->ctx);
>          in = BIO_new_mem_buf(ca, size);
>          inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
>          BIO_free(in);
>  
>          for (i = 0; i < sk_X509_INFO_num(inf); i++) {
> +            X509_INFO *itmp;
>              itmp = sk_X509_INFO_value(inf, i);
>              if (itmp->x509) {
>                  X509_STORE_add_cert(store, itmp->x509);


OT: Is there any preference about using declaration & definition, or
just definition if possible ?



More information about the Spice-devel mailing list