]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-upload: use _cleanup_ for curl_slist
authorDavid Tardon <dtardon@redhat.com>
Wed, 17 Mar 2021 12:25:47 +0000 (13:25 +0100)
committerDavid Tardon <dtardon@redhat.com>
Thu, 18 Mar 2021 08:41:49 +0000 (09:41 +0100)
src/journal-remote/journal-upload.c

index af53f98d133958b36b3ca2dcb4cb3854209cbd53..a8f1f7e5115b4793605d291b34019ad6c9a246eb 100644 (file)
@@ -72,6 +72,7 @@ static void close_fd_input(Uploader *u);
         } while (0)
 
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
 
 static size_t output_callback(char *buf,
                               size_t size,
@@ -182,27 +183,24 @@ int start_upload(Uploader *u,
         assert(input_callback);
 
         if (!u->header) {
-                struct curl_slist *h, *l;
+                _cleanup_(curl_slist_free_allp) struct curl_slist *h = NULL;
+                struct curl_slist *l;
 
                 h = curl_slist_append(NULL, "Content-Type: application/vnd.fdo.journal");
                 if (!h)
                         return log_oom();
 
                 l = curl_slist_append(h, "Transfer-Encoding: chunked");
-                if (!l) {
-                        curl_slist_free_all(h);
+                if (!l)
                         return log_oom();
-                }
                 h = l;
 
                 l = curl_slist_append(h, "Accept: text/plain");
-                if (!l) {
-                        curl_slist_free_all(h);
+                if (!l)
                         return log_oom();
-                }
                 h = l;
 
-                u->header = h;
+                u->header = TAKE_PTR(h);
         }
 
         if (!u->easy) {