-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
+/* SPDX-License-Identifier: LGPL-2.1+ */
#include <sys/xattr.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "hexdecoct.h"
+#include "import-util.h"
#include "io-util.h"
#include "machine-pool.h"
#include "parse-util.h"
+#include "pull-common.h"
#include "pull-job.h"
#include "string-util.h"
#include "strv.h"
#include "xattr-util.h"
-#include "pull-common.h"
-#include "import-util.h"
PullJob* pull_job_unref(PullJob *j) {
if (!j)
static void pull_job_finish(PullJob *j, int ret) {
assert(j);
- if (j->state == PULL_JOB_DONE ||
- j->state == PULL_JOB_FAILED)
+ if (IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED))
return;
if (ret == 0) {
return r;
free(j->url);
- free(j->payload);
j->url = chksum_url;
j->state = PULL_JOB_INIT;
- j->payload = NULL;
+ j->payload = mfree(j->payload);
j->payload_size = 0;
j->payload_allocated = 0;
j->written_compressed = 0;
return 0;
}
-
void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
PullJob *j = NULL;
CURLcode code;
if (curl_easy_getinfo(curl, CURLINFO_PRIVATE, (char **)&j) != CURLE_OK)
return;
- if (!j || j->state == PULL_JOB_DONE || j->state == PULL_JOB_FAILED)
+ if (!j || IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED))
return;
if (result != CURLE_OK) {
assert(contents);
assert(j);
- if (j->state == PULL_JOB_DONE || j->state == PULL_JOB_FAILED) {
+ if (IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED)) {
r = -ESTALE;
goto fail;
}
if (!j->url)
return -ENOMEM;
- *ret = j;
- j = NULL;
+ *ret = TAKE_PTR(j);
return 0;
}