X Tutup
Skip to content

Commit c4a2d47

Browse files
committed
journal-upload: use _cleanup_ for curl_slist
1 parent 3851069 commit c4a2d47

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/journal-remote/journal-upload.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static void close_fd_input(Uploader *u);
7272
} while (0)
7373

7474
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
75+
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
7576

7677
static size_t output_callback(char *buf,
7778
size_t size,
@@ -182,27 +183,24 @@ int start_upload(Uploader *u,
182183
assert(input_callback);
183184

184185
if (!u->header) {
185-
struct curl_slist *h, *l;
186+
_cleanup_(curl_slist_free_allp) struct curl_slist *h = NULL;
187+
struct curl_slist *l;
186188

187189
h = curl_slist_append(NULL, "Content-Type: application/vnd.fdo.journal");
188190
if (!h)
189191
return log_oom();
190192

191193
l = curl_slist_append(h, "Transfer-Encoding: chunked");
192-
if (!l) {
193-
curl_slist_free_all(h);
194+
if (!l)
194195
return log_oom();
195-
}
196196
h = l;
197197

198198
l = curl_slist_append(h, "Accept: text/plain");
199-
if (!l) {
200-
curl_slist_free_all(h);
199+
if (!l)
201200
return log_oom();
202-
}
203201
h = l;
204202

205-
u->header = h;
203+
u->header = TAKE_PTR(h);
206204
}
207205

208206
if (!u->easy) {

0 commit comments

Comments
 (0)
X Tutup