[Spice-devel,spice-gtk,v1,7/7] gtk-session: move variables to internal scope

Submitted by Victor Toso on Feb. 22, 2017, 1:11 p.m.

Details

Message ID 20170222131112.14079-8-victortoso@redhat.com
State New
Headers show
Series "clipboard_get_targets() on spice-gtk-session.c" ( rev: 3 2 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Feb. 22, 2017, 1:11 p.m.
From: Victor Toso <me@victortoso.com>

Signed-off-by: Victor Toso <victortoso@redhat.com>
---
 src/spice-gtk-session.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index cd546d3..595b327 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -613,8 +613,7 @@  static void clipboard_get_targets(GtkClipboard *clipboard,
 
     SpiceGtkSessionPrivate *s = self->priv;
     guint32 types[SPICE_N_ELEMENTS(atom2agent)] = { 0 };
-    char *name;
-    int a, m, t;
+    int a;
     int selection;
     gint num_types;
 
@@ -632,7 +631,9 @@  static void clipboard_get_targets(GtkClipboard *clipboard,
     /* Set all Atoms that matches our current protocol implementation */
     num_types = 0;
     for (a = 0; a < n_atoms; a++) {
-        name = gdk_atom_name(atoms[a]);
+        gint m, t;
+        gchar *name = gdk_atom_name(atoms[a]);
+
         for (m = 0; m < SPICE_N_ELEMENTS(atom2agent); m++) {
             if (strcasecmp(name, atom2agent[m].xatom) != 0) {
                 continue;

Comments

On Wed, 2017-02-22 at 14:11 +0100, Victor Toso wrote:
> From: Victor Toso <me@victortoso.com>
> 
> Signed-off-by: Victor Toso <victortoso@redhat.com>
> ---
>  src/spice-gtk-session.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index cd546d3..595b327 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -613,8 +613,7 @@ static void clipboard_get_targets(GtkClipboard
> *clipboard,
>  
>      SpiceGtkSessionPrivate *s = self->priv;
>      guint32 types[SPICE_N_ELEMENTS(atom2agent)] = { 0 };
> -    char *name;
> -    int a, m, t;
> +    int a;
>      int selection;
>      gint num_types;
>  
> @@ -632,7 +631,9 @@ static void clipboard_get_targets(GtkClipboard
> *clipboard,
>      /* Set all Atoms that matches our current protocol
> implementation */
>      num_types = 0;
>      for (a = 0; a < n_atoms; a++) {
> -        name = gdk_atom_name(atoms[a]);
> +        gint m, t;
t is used only in the 'm' for cycle - considering previous patches 

Also would be nice to change them to unsigned (they are compared with
an unsigned value)

Pavel

> +        gchar *name = gdk_atom_name(atoms[a]);
> +
>          for (m = 0; m < SPICE_N_ELEMENTS(atom2agent); m++) {
>              if (strcasecmp(name, atom2agent[m].xatom) != 0) {
>                  continue;
On Thu, Feb 23, 2017 at 02:26:09PM +0100, Pavel Grunt wrote:
> On Wed, 2017-02-22 at 14:11 +0100, Victor Toso wrote:
> > From: Victor Toso <me@victortoso.com>
> > 
> > Signed-off-by: Victor Toso <victortoso@redhat.com>
> > ---
> >  src/spice-gtk-session.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > index cd546d3..595b327 100644
> > --- a/src/spice-gtk-session.c
> > +++ b/src/spice-gtk-session.c
> > @@ -613,8 +613,7 @@ static void clipboard_get_targets(GtkClipboard
> > *clipboard,
> >  
> >      SpiceGtkSessionPrivate *s = self->priv;
> >      guint32 types[SPICE_N_ELEMENTS(atom2agent)] = { 0 };
> > -    char *name;
> > -    int a, m, t;
> > +    int a;
> >      int selection;
> >      gint num_types;
> >  
> > @@ -632,7 +631,9 @@ static void clipboard_get_targets(GtkClipboard
> > *clipboard,
> >      /* Set all Atoms that matches our current protocol
> > implementation */
> >      num_types = 0;
> >      for (a = 0; a < n_atoms; a++) {
> > -        name = gdk_atom_name(atoms[a]);
> > +        gint m, t;
> t is used only in the 'm' for cycle - considering previous patches
>
> Also would be nice to change them to unsigned (they are compared with
> an unsigned value)

Ok
>
> Pavel
>
> > +        gchar *name = gdk_atom_name(atoms[a]);
> > +
> >          for (m = 0; m < SPICE_N_ELEMENTS(atom2agent); m++) {
> >              if (strcasecmp(name, atom2agent[m].xatom) != 0) {
> >                  continue;