[Spice-commits] src/spice-gtk-session.c

Pavel Grunt pgrunt at kemper.freedesktop.org
Mon Feb 20 13:22:10 UTC 2017


 src/spice-gtk-session.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit 1a1fb7391afdbb2ed653aab38ad94eb81e4df9c1
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Fri Feb 17 13:44:55 2017 +0100

    gtk-session: Set value directly
    
    Related Coverity warning:
     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)) {
    
    There is no need for the "new_len" variable
    
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

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
@@ -917,11 +917,10 @@ 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'
@@ -930,10 +929,9 @@ static char *fixup_clipboard_text(SpiceGtkSession *self, const char *text, int *
          * send to the agent does not include any trailing '\0'
          * This is gtk+ bug https://bugzilla.gnome.org/show_bug.cgi?id=734670
          */
-        new_len = strlen(text);
+        *len = strlen(text);
     }
 
-    *len = new_len;
     return conv;
 }
 


More information about the Spice-commits mailing list