[seahorse/wip/nielsdg/server-source-props: 9/10] pgp: hkpsource: Cleanup get_send_result()




commit 103e60dafa7772cca67366cb4bcb4daff6a3f45d
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu Feb 18 13:08:03 2021 +0100

    pgp: hkpsource: Cleanup get_send_result()
    
    Use g_auto* to get auto-cleanup of variables and prefer stdint types
    over glib typedefs.

 pgp/seahorse-hkp-source.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/pgp/seahorse-hkp-source.c b/pgp/seahorse-hkp-source.c
index c053de2b..43547325 100644
--- a/pgp/seahorse-hkp-source.c
+++ b/pgp/seahorse-hkp-source.c
@@ -423,20 +423,19 @@ parse_hkp_index (const char *response)
 *
 * Returns NULL if there was no error. The error message else
 **/
-static gchar*
-get_send_result (const gchar *response)
+static char*
+get_send_result (const char *response)
 {
-    gchar **lines, **l;
-    gchar *t;
-    gchar *last = NULL;
+    g_auto(GStrv) lines = NULL;
+    char *last = NULL;
     gboolean is_error = FALSE;
 
     if (!*response)
         return g_strdup ("");
 
     lines = g_strsplit (response, "\n", 0);
-
-    for (l = lines; *l; l++) {
+    for (char **l = lines; *l; l++) {
+        g_autofree char *t = NULL;
 
         dehtmlize (*l);
         g_strstrip (*l);
@@ -444,24 +443,17 @@ get_send_result (const gchar *response)
         if (!(*l)[0])
             continue;
 
-        t = g_ascii_strdown (*l, -1);
-
         /* Look for the word 'error' */
+        t = g_ascii_strdown (*l, -1);
         if (strstr (t, "error"))
             is_error = TRUE;
 
-        g_free (t);
-
         if ((*l)[0])
             last = *l;
     }
 
     /* Use last line as the message */
-    last = is_error ? g_strdup (last) : NULL;
-
-    g_strfreev (lines);
-
-    return last;
+    return is_error ? g_strdup (last) : NULL;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]