Blob Blame History Raw
From f3092d6d61b7095517960faa967bd4c0c2ab4cb8 Mon Sep 17 00:00:00 2001
From: Pavel Grunt <pgrunt@redhat.com>
Date: Fri, 2 Sep 2016 11:24:43 +0200
Subject: [PATCH 22/23] util: Remove unused GError parameter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The parameter is removed from functions:
 get_line
 spice_convert_newlines
 spice_unix2dos
 spice_dos2unix

It was introduced in 75f1ea3ee9c4dbd6c5f27896caee07792bbdbba4
but never used

Acked-by: Marc-André Lureau <mlureau@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
(cherry picked from commit b708989b12122af39144b856576c2dd234130b9c)
---
 src/spice-gtk-session.c | 22 ++--------------------
 src/spice-util-priv.h   |  4 ++--
 src/spice-util.c        | 28 ++++++++--------------------
 tests/util.c            | 14 ++++----------
 4 files changed, 16 insertions(+), 52 deletions(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 3ab1465..5ebc7c2 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -708,15 +708,7 @@ static void clipboard_got_from_guest(SpiceMainChannel *main, guint selection,
         /* on windows, gtk+ would already convert to LF endings, but
            not on unix */
         if (spice_main_agent_test_capability(s->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
-            GError *err = NULL;
-
-            conv = spice_dos2unix((gchar*)data, size, &err);
-            if (err) {
-                g_warning("Failed to convert text line ending: %s", err->message);
-                g_clear_error(&err);
-                goto end;
-            }
-
+            conv = spice_dos2unix((gchar*)data, size);
             size = strlen(conv);
         }
 
@@ -727,7 +719,6 @@ static void clipboard_got_from_guest(SpiceMainChannel *main, guint selection,
             8, data, size);
     }
 
-end:
     if (g_main_loop_is_running (ri->loop))
         g_main_loop_quit (ri->loop);
 
@@ -894,17 +885,8 @@ static char *fixup_clipboard_text(SpiceGtkSession *self, const char *text, int *
     char *conv = NULL;
     int new_len = *len;
 
-
     if (spice_main_agent_test_capability(self->priv->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
-        GError *err = NULL;
-
-        conv = spice_unix2dos(text, *len, &err);
-        if (err) {
-            g_warning("Failed to convert text line ending: %s", err->message);
-            g_clear_error(&err);
-            return NULL;
-        }
-
+        conv = spice_unix2dos(text, *len);
         new_len = strlen(conv);
     } else {
         /* On Windows, with some versions of gtk+, GtkSelectionData::length
diff --git a/src/spice-util-priv.h b/src/spice-util-priv.h
index c0ea8d9..10a3d48 100644
--- a/src/spice-util-priv.h
+++ b/src/spice-util-priv.h
@@ -28,8 +28,8 @@ G_BEGIN_DECLS
 gboolean spice_strv_contains(const GStrv strv, const gchar *str);
 const gchar* spice_yes_no(gboolean value);
 guint16 spice_make_scancode(guint scancode, gboolean release);
-gchar* spice_unix2dos(const gchar *str, gssize len, GError **error);
-gchar* spice_dos2unix(const gchar *str, gssize len, GError **error);
+gchar* spice_unix2dos(const gchar *str, gssize len);
+gchar* spice_dos2unix(const gchar *str, gssize len);
 void spice_mono_edge_highlight(unsigned width, unsigned hight,
                                const guint8 *and, const guint8 *xor, guint8 *dest);
 
diff --git a/src/spice-util.c b/src/spice-util.c
index fd97ee7..2b9cb2f 100644
--- a/src/spice-util.c
+++ b/src/spice-util.c
@@ -292,8 +292,7 @@ typedef enum {
 } NewlineType;
 
 static gssize get_line(const gchar *str, gsize len,
-                       NewlineType type, gsize *nl_len,
-                       GError **error)
+                       NewlineType type, gsize *nl_len)
 {
     const gchar *p, *endl;
     gsize nl = 0;
@@ -312,19 +311,15 @@ static gssize get_line(const gchar *str, gsize len,
 
 static gchar* spice_convert_newlines(const gchar *str, gssize len,
                                      NewlineType from,
-                                     NewlineType to,
-                                     GError **error)
+                                     NewlineType to)
 {
-    GError *err = NULL;
     gssize length;
     gsize nl;
     GString *output;
-    gboolean free_segment = FALSE;
     gint i;
 
     g_return_val_if_fail(str != NULL, NULL);
     g_return_val_if_fail(len >= -1, NULL);
-    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
     /* only 2 supported combinations */
     g_return_val_if_fail((from == NEWLINE_TYPE_LF &&
                           to == NEWLINE_TYPE_CR_LF) ||
@@ -345,7 +340,7 @@ static gchar* spice_convert_newlines(const gchar *str, gssize len,
     output = g_string_sized_new(len * 2 + 1);
 
     for (i = 0; i < len; i += length + nl) {
-        length = get_line(str + i, len - i, from, &nl, &err);
+        length = get_line(str + i, len - i, from, &nl);
         if (length < 0)
             break;
 
@@ -361,30 +356,23 @@ static gchar* spice_convert_newlines(const gchar *str, gssize len,
         }
     }
 
-    if (err) {
-        g_propagate_error(error, err);
-        free_segment = TRUE;
-    }
-
-    return g_string_free(output, free_segment);
+    return g_string_free(output, FALSE);
 }
 
 G_GNUC_INTERNAL
-gchar* spice_dos2unix(const gchar *str, gssize len, GError **error)
+gchar* spice_dos2unix(const gchar *str, gssize len)
 {
     return spice_convert_newlines(str, len,
                                   NEWLINE_TYPE_CR_LF,
-                                  NEWLINE_TYPE_LF,
-                                  error);
+                                  NEWLINE_TYPE_LF);
 }
 
 G_GNUC_INTERNAL
-gchar* spice_unix2dos(const gchar *str, gssize len, GError **error)
+gchar* spice_unix2dos(const gchar *str, gssize len)
 {
     return spice_convert_newlines(str, len,
                                   NEWLINE_TYPE_LF,
-                                  NEWLINE_TYPE_CR_LF,
-                                  error);
+                                  NEWLINE_TYPE_CR_LF);
 }
 
 static bool buf_is_ones(unsigned size, const guint8 *data)
diff --git a/tests/util.c b/tests/util.c
index b9b9535..14862a5 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -34,7 +34,6 @@ static const struct {
 
 static void test_dos2unix(void)
 {
-    GError *err = NULL;
     gchar *tmp;
     unsigned int i;
 
@@ -42,22 +41,19 @@ static void test_dos2unix(void)
         if (!(dosunix[i].flags & DOS2UNIX))
             continue;
 
-        tmp = spice_dos2unix(dosunix[i].d, -1, &err);
+        tmp = spice_dos2unix(dosunix[i].d, -1);
         g_assert_cmpstr(tmp, ==, dosunix[i].u);
-        g_assert_no_error(err);
         g_free(tmp);
 
         /* including ending \0 */
-        tmp = spice_dos2unix(dosunix[i].d, strlen(dosunix[i].d) + 1, &err);
+        tmp = spice_dos2unix(dosunix[i].d, strlen(dosunix[i].d) + 1);
         g_assert_cmpstr(tmp, ==, dosunix[i].u);
-        g_assert_no_error(err);
         g_free(tmp);
     }
 }
 
 static void test_unix2dos(void)
 {
-    GError *err = NULL;
     gchar *tmp;
     unsigned int i;
 
@@ -65,15 +61,13 @@ static void test_unix2dos(void)
         if (!(dosunix[i].flags & UNIX2DOS))
             continue;
 
-        tmp = spice_unix2dos(dosunix[i].u, -1, &err);
+        tmp = spice_unix2dos(dosunix[i].u, -1);
         g_assert_cmpstr(tmp, ==, dosunix[i].d);
-        g_assert_no_error(err);
         g_free(tmp);
 
         /* including ending \0 */
-        tmp = spice_unix2dos(dosunix[i].u, strlen(dosunix[i].u) + 1, &err);
+        tmp = spice_unix2dos(dosunix[i].u, strlen(dosunix[i].u) + 1);
         g_assert_cmpstr(tmp, ==, dosunix[i].d);
-        g_assert_no_error(err);
         g_free(tmp);
     }
 }
-- 
2.10.0