[Spice-devel] [PATCH spice-gtk] gtk-session: Set value directly

Pavel Grunt pgrunt at redhat.com
Fri Feb 17 16:17:16 UTC 2017


On Fri, 2017-02-17 at 10:01 -0600, Jonathon Jongsma wrote:
> On Fri, 2017-02-17 at 13:44 +0100, Pavel Grunt wrote:
> > Spotted by coverity
> 
> Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
> 
> out of curiosity, what did coverity actually say here?
> 

spice-gtk-0.33.53-7cb7-dirty/src/spice-gtk-session.c:920:9: note:
Value stored to 'new_len' during its initialization is never read
#    int new_len = *len;
#        ^~~~~~~   ~~~~
#  918|   {
#  919|       char *conv = NULL;
#  920|->     int new_len = *len;
#  921|   
#  922|       if (spice_main_agent_test_capability(self->priv->main,
VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {

> 
> > ---
> >  src/spice-gtk-session.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > index a3a2e90..5688cba 100644
> > --- a/src/spice-gtk-session.c
> > +++ b/src/spice-gtk-session.c
> > @@ -916,25 +916,23 @@ static gboolean
> > check_clipboard_size_limits(SpiceGtkSession *session,
> >   */
> >  static char *fixup_clipboard_text(SpiceGtkSession *self, const
> > char
> > *text, int *len)
> >  {
> >      char *conv = NULL;
> > -    int new_len = *len;
> >  
> >      if (spice_main_agent_test_capability(self->priv->main,
> > VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
> >          conv = spice_unix2dos(text, *len);
> > -        new_len = strlen(conv);
> > +        *len = strlen(conv);
> >      } else {
> >          /* On Windows, with some versions of gtk+,
> > GtkSelectionData::length
> >           * will include the final '\0'. When a string with this
> > trailing '\0'
> >           * is pasted in some linux applications, it will be
> > pasted
> > as <NIL> or
> >           * as an invisible character, which is unwanted. Ensure
> > the
> > length we
> >           * send to the agent does not include any trailing '\0'
> >           * This is gtk+ bug https://bugzilla.gnome.org/show_bug.c
> > gi?
> > id=734670
> >           */
> > -        new_len = strlen(text);
> > +        *len = strlen(text);
> >      }
> >  
> > -    *len = new_len;
> >      return conv;
> >  }
> >  
> >  static void clipboard_received_text_cb(GtkClipboard *clipboard,


More information about the Spice-devel mailing list