diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-24 03:14:32 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-24 03:14:32 +0900 |
commit | c3e658004a66115fa09abcf602d573e65e577aa9 (patch) | |
tree | 2376c221e7ad727a248b71603740e646138afdf3 /src/import | |
parent | 1e268f423c66b818da70fbb30c3fb7657cd93080 (diff) | |
download | systemd-c3e658004a66115fa09abcf602d573e65e577aa9.tar.gz |
import: use _cleanup_ attribute for CURL object
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/curl-util.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 48dc9d1963..24011860f7 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -258,9 +258,8 @@ int curl_glue_new(CurlGlue **glue, sd_event *event) { } int curl_glue_make(CURL **ret, const char *url, void *userdata) { + _cleanup_(curl_easy_cleanupp) CURL *c = NULL; const char *useragent; - CURL *c; - int r; assert(ret); assert(url); @@ -271,33 +270,21 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) { /* curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); */ - if (curl_easy_setopt(c, CURLOPT_URL, url) != CURLE_OK) { - r = -EIO; - goto fail; - } + if (curl_easy_setopt(c, CURLOPT_URL, url) != CURLE_OK) + return -EIO; - if (curl_easy_setopt(c, CURLOPT_PRIVATE, userdata) != CURLE_OK) { - r = -EIO; - goto fail; - } + if (curl_easy_setopt(c, CURLOPT_PRIVATE, userdata) != CURLE_OK) + return -EIO; useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION); - if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK) { - r = -EIO; - goto fail; - } + if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK) + return -EIO; - if (curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L) != CURLE_OK) { - r = -EIO; - goto fail; - } + if (curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L) != CURLE_OK) + return -EIO; *ret = c; return 0; - -fail: - curl_easy_cleanup(c); - return r; } int curl_glue_add(CurlGlue *g, CURL *c) { |