diff options
author | Richard Hughes <richard@hughsie.com> | 2016-11-09 20:46:39 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-11-09 20:46:39 +0000 |
commit | ff79392430e7f76ddaca83420dc873444fe943cd (patch) | |
tree | 450fd1221698b8f101587cdbe4a6c7ba3ef6a907 | |
parent | 98a76bc4c67270a94764e42291f215826feb678c (diff) | |
download | appstream-glib-ff79392430e7f76ddaca83420dc873444fe943cd.tar.gz |
trivial: Use g_autoptr to avoid a Coverity warning
-rw-r--r-- | client/as-util.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/client/as-util.c b/client/as-util.c index 7b7106b..8768ae5 100644 --- a/client/as-util.c +++ b/client/as-util.c @@ -3159,13 +3159,13 @@ as_util_mirror_screenshots_app_url (AsUtilPrivate *priv, gboolean is_default; gboolean ret = TRUE; SoupStatus status; - SoupURI *uri = NULL; g_autofree gchar *basename = NULL; g_autofree gchar *cache_filename = NULL; g_autoptr(AsImage) im = NULL; g_autoptr(AsScreenshot) ss = NULL; g_autoptr(SoupMessage) msg = NULL; g_autoptr(SoupSession) session = NULL; + g_autoptr(SoupURI) uri = NULL; /* fonts screenshots are auto-generated */ if (as_app_get_kind (app) == AS_APP_KIND_FONT) { @@ -3202,24 +3202,22 @@ as_util_mirror_screenshots_app_url (AsUtilPrivate *priv, } else { uri = soup_uri_new (url); if (uri == NULL) { - ret = FALSE; g_set_error (error, AS_ERROR, AS_ERROR_FAILED, "Could not parse '%s' as a URL", url); - goto out; + return FALSE; } msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri); as_util_app_log (app, "Downloading %s", url); status = soup_session_send_message (session, msg); if (status != SOUP_STATUS_OK) { - ret = FALSE; g_set_error (error, AS_ERROR, AS_ERROR_FAILED, "Downloading failed: %s", soup_status_get_phrase (status)); - goto out; + return FALSE; } /* save new file */ @@ -3228,7 +3226,7 @@ as_util_mirror_screenshots_app_url (AsUtilPrivate *priv, (gssize) msg->response_body->length, error); if (!ret) - goto out; + return FALSE; as_util_app_log (app, "Saved to cache %s", cache_filename); } @@ -3244,18 +3242,12 @@ as_util_mirror_screenshots_app_url (AsUtilPrivate *priv, as_app_add_screenshot (app, ss); /* mirror the filename */ - ret = as_util_mirror_screenshots_app_file (app, - ss, - cache_filename, - mirror_uri, - output_dir, - error); - if (!ret) - goto out; -out: - if (uri != NULL) - soup_uri_free (uri); - return ret; + return as_util_mirror_screenshots_app_file (app, + ss, + cache_filename, + mirror_uri, + output_dir, + error); } static gboolean |