[evolution-data-server] M!23 - Use the return value of g_string_free(*, FALSE)
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] M!23 - Use the return value of g_string_free(*, FALSE)
- Date: Thu, 11 Jul 2019 08:09:55 +0000 (UTC)
commit 277c363924b9b7daf272c625984796fc76c0cc5d
Author: Дилян Палаузов <git-dpa aegee org>
Date: Sat Jul 6 21:22:49 2019 +0000
M!23 - Use the return value of g_string_free(*, FALSE)
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/merge_requests/23
src/addressbook/libebook-contacts/e-contact.c | 5 +-
.../libedata-book/e-book-backend-sqlitedb.c | 3 +-
src/calendar/libecal/e-cal-client.c | 4 +-
src/calendar/libecal/e-reminder-watcher.c | 6 +-
src/camel/camel-internet-address.c | 18 +----
src/camel/camel-mime-message.c | 6 +-
src/camel/camel-mime-utils.c | 83 +++++-----------------
src/camel/camel-nntp-address.c | 6 +-
src/camel/camel-search-sql-sexp.c | 18 ++---
src/camel/camel-sexp.c | 3 +-
src/camel/camel-url.c | 11 +--
src/camel/providers/imapx/camel-imapx-utils.c | 7 +-
src/libedataserver/e-sexp.c | 3 +-
13 files changed, 40 insertions(+), 133 deletions(-)
---
diff --git a/src/addressbook/libebook-contacts/e-contact.c b/src/addressbook/libebook-contacts/e-contact.c
index c5dd99d29..fa898ecff 100644
--- a/src/addressbook/libebook-contacts/e-contact.c
+++ b/src/addressbook/libebook-contacts/e-contact.c
@@ -1663,7 +1663,6 @@ e_contact_get (EContact *contact,
}
case E_CONTACT_CATEGORIES: {
EVCardAttribute *attr = e_vcard_get_attribute (E_VCARD (contact), EVC_CATEGORIES);
- gchar *rv = NULL;
if (attr) {
GString *str = g_string_new ("");
@@ -1675,9 +1674,9 @@ e_contact_get (EContact *contact,
g_string_append_c (str, ',');
}
- rv = g_string_free (str, FALSE);
+ return g_string_free (str, FALSE);
}
- return rv;
+ return NULL;
}
default:
g_warning ("unhandled synthetic field 0x%02x", info->field_id);
diff --git a/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
b/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
index a8abc60de..d5a56dba1 100644
--- a/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -3846,8 +3846,7 @@ convert_match_exp (struct _ESExp *f,
g_free (query_term);
}
- str = names->str;
- g_string_free (names, FALSE);
+ str = g_string_free (names, FALSE);
} else {
const gchar *const region =
diff --git a/src/calendar/libecal/e-cal-client.c b/src/calendar/libecal/e-cal-client.c
index 8b7622d3d..7e2738355 100644
--- a/src/calendar/libecal/e-cal-client.c
+++ b/src/calendar/libecal/e-cal-client.c
@@ -3198,11 +3198,9 @@ e_cal_client_get_component_as_string (ECalClient *client,
g_string_append (vcal_string, "END:VCALENDAR\r\n");
g_free (obj_string);
- obj_string = g_string_free (vcal_string, FALSE);
-
g_hash_table_destroy (timezone_hash);
- return obj_string;
+ return g_string_free (vcal_string, FALSE);
}
/* Helper for e_cal_client_get_default_object() */
diff --git a/src/calendar/libecal/e-reminder-watcher.c b/src/calendar/libecal/e-reminder-watcher.c
index 78176239c..919d297f4 100644
--- a/src/calendar/libecal/e-reminder-watcher.c
+++ b/src/calendar/libecal/e-reminder-watcher.c
@@ -2642,7 +2642,6 @@ e_reminder_watcher_describe_data (EReminderWatcher *watcher,
guint32 flags)
{
ICalComponent *icalcomp;
- gchar *description = NULL;
gboolean use_markup;
g_return_val_if_fail (E_IS_REMINDER_WATCHER (watcher), NULL);
@@ -2771,13 +2770,12 @@ e_reminder_watcher_describe_data (EReminderWatcher *watcher,
}
}
- description = g_string_free (markup, FALSE);
-
g_free (timediff);
g_free (summary);
+ return g_string_free (markup, FALSE);
}
- return description;
+ return NULL;
}
typedef struct _ForeachTriggerData {
diff --git a/src/camel/camel-internet-address.c b/src/camel/camel-internet-address.c
index d8269fe40..f920e31f0 100644
--- a/src/camel/camel-internet-address.c
+++ b/src/camel/camel-internet-address.c
@@ -83,7 +83,6 @@ internet_address_encode (CamelAddress *paddr)
CamelInternetAddress *inet_addr = CAMEL_INTERNET_ADDRESS (paddr);
gint i;
GString *out;
- gchar *ret;
gint len = 6; /* "From: ", assume longer of the address headers */
if (inet_addr->priv->addresses->len == 0)
@@ -103,10 +102,7 @@ internet_address_encode (CamelAddress *paddr)
g_free (enc);
}
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
static gint
@@ -183,7 +179,6 @@ internet_address_format (CamelAddress *paddr)
CamelInternetAddress *inet_addr = CAMEL_INTERNET_ADDRESS (paddr);
gint i;
GString *out;
- gchar *ret;
if (inet_addr->priv->addresses->len == 0)
return NULL;
@@ -202,10 +197,7 @@ internet_address_format (CamelAddress *paddr)
g_free (enc);
}
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
static void
@@ -566,7 +558,6 @@ camel_internet_address_encode_address (gint *inlen,
const gchar *addr)
{
gchar *name;
- gchar *ret = NULL;
gint len = 0;
GString *out;
@@ -620,10 +611,7 @@ camel_internet_address_encode_address (gint *inlen,
g_free (name);
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
/**
diff --git a/src/camel/camel-mime-message.c b/src/camel/camel-mime-message.c
index 319782cea..3f55197cd 100644
--- a/src/camel/camel-mime-message.c
+++ b/src/camel/camel-mime-message.c
@@ -1267,7 +1267,6 @@ camel_mime_message_build_mbox_from (CamelMimeMessage *message)
{
const CamelNameValueArray *headers;
GString *out = g_string_new ("From ");
- gchar *ret;
const gchar *tmp;
time_t thetime;
gint offset;
@@ -1318,10 +1317,7 @@ camel_mime_message_build_mbox_from (CamelMimeMessage *message)
tm.tm_sec,
tm.tm_year + 1900);
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
static gboolean
diff --git a/src/camel/camel-mime-utils.c b/src/camel/camel-mime-utils.c
index 5d7db4bc0..a3252efd8 100644
--- a/src/camel/camel-mime-utils.c
+++ b/src/camel/camel-mime-utils.c
@@ -1448,9 +1448,7 @@ header_decode_text (const gchar *in,
}
}
- decoded = g_string_free (out, FALSE);
-
- return decoded;
+ return g_string_free (out, FALSE);
}
/**
@@ -1627,7 +1625,6 @@ header_encode_string_rfc2047 (const guchar *in,
const gchar *charset;
gint encoding;
GString *out;
- gchar *outstr;
g_return_val_if_fail (g_utf8_validate ((const gchar *) in, -1, NULL), NULL);
@@ -1744,10 +1741,7 @@ header_encode_string_rfc2047 (const guchar *in,
}
}
- outstr = out->str;
- g_string_free (out, FALSE);
-
- return outstr;
+ return g_string_free (out, FALSE);
}
/* TODO: Should this worry about quotes?? */
@@ -1958,7 +1952,6 @@ camel_header_encode_phrase (const guchar *in)
GList *words, *wordl;
const gchar *charset;
GString *out;
- gchar *outstr;
if (in == NULL)
return NULL;
@@ -2028,10 +2021,7 @@ camel_header_encode_phrase (const guchar *in)
g_free (word);
g_list_free (words);
- outstr = out->str;
- g_string_free (out, FALSE);
-
- return outstr;
+ return g_string_free (out, FALSE);
}
/* these are all internal parser functions */
@@ -2558,7 +2548,6 @@ header_decode_domain (const gchar **in)
{
const gchar *inptr = *in;
gint go = TRUE;
- gchar *ret;
GString *domain = g_string_new ("");
/* domain ref | domain literal */
@@ -2599,9 +2588,7 @@ header_decode_domain (const gchar **in)
*in = inptr;
- ret = domain->str;
- g_string_free (domain, FALSE);
- return ret;
+ return g_string_free (domain, FALSE);
}
static gchar *
@@ -2654,9 +2641,7 @@ header_decode_addrspec (const gchar **in)
/* FIXME: return null on error? */
*in = inptr;
- word = addr->str;
- g_string_free (addr, FALSE);
- return word;
+ return g_string_free (addr, FALSE);
}
/*
@@ -3139,10 +3124,7 @@ camel_header_contentid_decode (const gchar *in)
header_decode_lwsp (&inptr);
}
- buf = addr->str;
- g_string_free (addr, FALSE);
-
- return buf;
+ return g_string_free (addr, FALSE);
}
static void
@@ -3519,13 +3501,13 @@ header_encode_param (const guchar *in,
const gchar *charset;
GString *out;
guint32 c;
- gchar *str;
*encoded = FALSE;
g_return_val_if_fail (in != NULL, NULL);
if (is_filename) {
+ gchar *str;
if (!g_utf8_validate ((gchar *) inptr, -1, NULL)) {
GString *buff = g_string_new ("");
@@ -3572,12 +3554,9 @@ header_encode_param (const guchar *in,
g_string_append_printf (out, "%%%c%c", tohex[(c >> 4) & 0xf], tohex[c & 0xf]);
}
g_free (outbuf);
-
- str = out->str;
- g_string_free (out, FALSE);
*encoded = TRUE;
- return str;
+ return g_string_free (out, FALSE);
}
/* HACK: Set to non-zero when you want the 'filename' and 'name' headers encoded in RFC 2047 way,
@@ -3699,12 +3678,9 @@ gchar *
camel_header_param_list_format (struct _camel_header_param *p)
{
GString *out = g_string_new ("");
- gchar *ret;
camel_header_param_list_format_append (out, p);
- ret = out->str;
- g_string_free (out, FALSE);
- return ret;
+ return g_string_free (out, FALSE);
}
CamelContentType *
@@ -3768,7 +3744,6 @@ gchar *
camel_content_type_format (CamelContentType *ct)
{
GString *out;
- gchar *ret;
if (ct == NULL)
return NULL;
@@ -3788,10 +3763,7 @@ camel_content_type_format (CamelContentType *ct)
}
camel_header_param_list_format_append (out, ct->params);
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
gchar *
@@ -3880,7 +3852,6 @@ gchar *
camel_content_disposition_format (CamelContentDisposition *d)
{
GString *out;
- gchar *ret;
if (d == NULL)
return NULL;
@@ -3892,9 +3863,7 @@ camel_content_disposition_format (CamelContentDisposition *d)
out = g_string_append (out, "attachment");
camel_header_param_list_format_append (out, d->params);
- ret = out->str;
- g_string_free (out, FALSE);
- return ret;
+ return g_string_free (out, FALSE);
}
gboolean
@@ -4581,7 +4550,7 @@ camel_header_location_decode (const gchar *in)
{
gint quote = 0;
GString *out = g_string_new ("");
- gchar c, *res;
+ gchar c;
/* Sigh. RFC2557 says:
* content-location = "Content-Location:" [CFWS] URI [CFWS]
@@ -4613,10 +4582,7 @@ camel_header_location_decode (const gchar *in)
g_string_append_c (out, c);
}
- res = g_strdup (out->str);
- g_string_free (out, TRUE);
-
- return res;
+ return g_string_free (out, FALSE);
}
/**
@@ -5104,17 +5070,13 @@ gchar *
camel_header_address_list_encode (CamelHeaderAddress *addrlist)
{
GString *out;
- gchar *ret;
if (!addrlist)
return NULL;
out = g_string_new ("");
header_address_list_encode_append (out, TRUE, addrlist);
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
/**
@@ -5128,7 +5090,6 @@ gchar *
camel_header_address_list_format (CamelHeaderAddress *addrlist)
{
GString *out;
- gchar *ret;
if (!addrlist)
return NULL;
@@ -5136,10 +5097,8 @@ camel_header_address_list_format (CamelHeaderAddress *addrlist)
out = g_string_new ("");
header_address_list_encode_append (out, FALSE, addrlist);
- ret = out->str;
- g_string_free (out, FALSE);
- return ret;
+ return g_string_free (out, FALSE);
}
gchar *
@@ -5149,7 +5108,6 @@ camel_header_address_fold (const gchar *in,
gsize len, outlen;
const gchar *inptr = in, *space, *p, *n;
GString *out;
- gchar *ret;
gint i, needunfold = FALSE;
if (in == NULL)
@@ -5208,13 +5166,10 @@ camel_header_address_fold (const gchar *in,
inptr += len;
}
- ret = out->str;
- g_string_free (out, FALSE);
-
if (needunfold)
g_free ((gchar *) in);
- return ret;
+ return g_string_free (out, FALSE);
}
/* simple header folding */
@@ -5226,7 +5181,6 @@ camel_header_fold (const gchar *in,
gsize len, outlen, tmplen;
const gchar *inptr = in, *space, *p, *n;
GString *out;
- gchar *ret;
gint needunfold = FALSE;
gchar spc;
@@ -5297,13 +5251,10 @@ camel_header_fold (const gchar *in,
outlen += len;
inptr += len;
}
- ret = out->str;
- g_string_free (out, FALSE);
-
if (needunfold)
g_free ((gchar *) in);
- return ret;
+ return g_string_free (out, FALSE);
}
gchar *
diff --git a/src/camel/camel-nntp-address.c b/src/camel/camel-nntp-address.c
index a67ccf6cc..fa58129aa 100644
--- a/src/camel/camel-nntp-address.c
+++ b/src/camel/camel-nntp-address.c
@@ -65,7 +65,6 @@ nntp_address_encode (CamelAddress *address)
CamelNNTPAddress *nntp_addr = CAMEL_NNTP_ADDRESS (address);
gint i;
GString *out;
- gchar *ret;
if (nntp_addr->priv->addresses->len == 0)
return NULL;
@@ -79,10 +78,7 @@ nntp_address_encode (CamelAddress *address)
g_string_append (out, g_ptr_array_index (nntp_addr->priv->addresses, i));
}
- ret = out->str;
- g_string_free (out, FALSE);
-
- return ret;
+ return g_string_free (out, FALSE);
}
static gint
diff --git a/src/camel/camel-search-sql-sexp.c b/src/camel/camel-search-sql-sexp.c
index feaab11ca..72489694a 100644
--- a/src/camel/camel-search-sql-sexp.c
+++ b/src/camel/camel-search-sql-sexp.c
@@ -133,8 +133,7 @@ func_or (CamelSExp *f,
g_string_append (string, " )");
r = camel_sexp_result_new (f, CAMEL_SEXP_RES_STRING);
- r->value.string = string->str;
- g_string_free (string, FALSE);
+ r->value.string = g_string_free (string, FALSE);
return r;
}
@@ -230,8 +229,7 @@ eval_eq (struct _CamelSExp *f,
camel_sexp_result_free (f, r1);
camel_sexp_result_free (f, r2);
g_string_append (str, " )");
- r->value.string = str->str;
- g_string_free (str, FALSE);
+ r->value.string = g_string_free (str, FALSE);
} else {
r->value.string = g_strdup ("(0)");
}
@@ -273,8 +271,7 @@ eval_lt (struct _CamelSExp *f,
camel_sexp_result_free (f, r2);
g_string_append (str, " )");
- r->value.string = str->str;
- g_string_free (str, FALSE);
+ r->value.string = g_string_free (str, FALSE);
}
return r;
}
@@ -315,8 +312,7 @@ eval_gt (struct _CamelSExp *f,
camel_sexp_result_free (f, r2);
g_string_append (str, " )");
- r->value.string = str->str;
- g_string_free (str, FALSE);
+ r->value.string = g_string_free (str, FALSE);
}
return r;
}
@@ -364,8 +360,7 @@ match_threads (struct _CamelSExp *f,
g_string_append (str, " )");
r = camel_sexp_result_new (f, CAMEL_SEXP_RES_STRING);
- r->value.string = str->str;
- g_string_free (str, FALSE);
+ r->value.string = g_string_free (str, FALSE);
return r;
}
@@ -761,8 +756,7 @@ sql_exp (struct _CamelSExp *f,
if (argv[i]->type == CAMEL_SEXP_RES_STRING && argv[i]->value.string)
g_string_append (str, argv[i]->value.string);
}
- r->value.string = str->str;
- g_string_free (str, FALSE);
+ r->value.string = g_string_free (str, FALSE);
return r;
}
diff --git a/src/camel/camel-sexp.c b/src/camel/camel-sexp.c
index bf9a20011..3edccc949 100644
--- a/src/camel/camel-sexp.c
+++ b/src/camel/camel-sexp.c
@@ -604,8 +604,7 @@ term_eval_plus (CamelSExp *sexp,
camel_sexp_fatal_error (sexp, "Invalid types in (+ strings)");
}
result = camel_sexp_result_new (sexp, CAMEL_SEXP_RES_STRING);
- result->value.string = string->str;
- g_string_free (string, FALSE);
+ result->value.string = g_string_free (string, FALSE);
break; }
case CAMEL_SEXP_RES_TIME: {
time_t total;
diff --git a/src/camel/camel-url.c b/src/camel/camel-url.c
index 7f5e21be4..49dfe786a 100644
--- a/src/camel/camel-url.c
+++ b/src/camel/camel-url.c
@@ -342,7 +342,6 @@ camel_url_to_string (CamelURL *url,
CamelURLFlags flags)
{
GString *str;
- gchar *return_result;
g_return_val_if_fail (url != NULL, NULL);
@@ -390,10 +389,7 @@ camel_url_to_string (CamelURL *url,
append_url_encoded (str, url->fragment, NULL);
}
- return_result = str->str;
- g_string_free (str, FALSE);
-
- return return_result;
+ return g_string_free (str, FALSE);
}
static void
@@ -664,16 +660,13 @@ camel_url_encode (const gchar *part,
const gchar *escape_extra)
{
GString *str;
- gchar *encoded;
g_return_val_if_fail (part != NULL, NULL);
str = g_string_new (NULL);
append_url_encoded (str, part, escape_extra);
- encoded = str->str;
- g_string_free (str, FALSE);
- return encoded;
+ return g_string_free (str, FALSE);
}
/**
diff --git a/src/camel/providers/imapx/camel-imapx-utils.c b/src/camel/providers/imapx/camel-imapx-utils.c
index 38b8a5b0c..f5a12171a 100644
--- a/src/camel/providers/imapx/camel-imapx-utils.c
+++ b/src/camel/providers/imapx/camel-imapx-utils.c
@@ -3524,7 +3524,7 @@ imapx_path_to_physical (const gchar *prefix,
{
GString *out = g_string_new (prefix);
const gchar *p = vpath;
- gchar c, *res;
+ gchar c;
g_string_append_c (out, '/');
p = vpath;
@@ -3537,10 +3537,7 @@ imapx_path_to_physical (const gchar *prefix,
g_string_append_c (out, c);
}
- res = out->str;
- g_string_free (out, FALSE);
-
- return res;
+ return g_string_free (out, FALSE);
}
gchar *
diff --git a/src/libedataserver/e-sexp.c b/src/libedataserver/e-sexp.c
index 759a9059d..5238b8f1c 100644
--- a/src/libedataserver/e-sexp.c
+++ b/src/libedataserver/e-sexp.c
@@ -564,8 +564,7 @@ term_eval_plus (ESExp *sexp,
e_sexp_fatal_error (sexp, "Invalid types in (+ strings)");
}
r = e_sexp_result_new (sexp, ESEXP_RES_STRING);
- r->value.string = s->str;
- g_string_free (s, FALSE);
+ r->value.string = g_string_free (s, FALSE);
break; }
case ESEXP_RES_TIME: {
time_t total;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]