autoupdater: uclient: remove early returns from get_url()

Simplify control flow by removing early returns. This allows us to
deduplicate cleanup (uclient_free() for now).
This commit is contained in:
Matthias Schiffer 2023-02-24 20:26:33 +01:00
parent 04d2b6ffbb
commit 5521926500
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 7 additions and 5 deletions

View File

@ -159,6 +159,7 @@ int get_url(const char *url, void (*read_cb)(struct uclient *cl), void *cb_data,
.data_eof = eof_cb,
.error = request_done,
};
int ret = UCLIENT_ERROR_CONNECT;
struct uclient *cl = uclient_new(url, NULL, &cb);
if (!cl)
@ -182,16 +183,17 @@ int get_url(const char *url, void (*read_cb)(struct uclient *cl), void *cb_data,
if (uclient_request(cl))
goto err;
uloop_run();
uclient_free(cl);
if (!d.err_code && d.length >= 0 && d.downloaded != d.length)
return UCLIENT_ERROR_SIZE_MISMATCH;
if (!d.err_code && d.length >= 0 && d.downloaded != d.length) {
ret = UCLIENT_ERROR_SIZE_MISMATCH;
goto err;
}
return d.err_code;
ret = d.err_code;
err:
if (cl)
uclient_free(cl);
return UCLIENT_ERROR_CONNECT;
return ret;
}