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:
parent
04d2b6ffbb
commit
5521926500
|
@ -159,6 +159,7 @@ int get_url(const char *url, void (*read_cb)(struct uclient *cl), void *cb_data,
|
||||||
.data_eof = eof_cb,
|
.data_eof = eof_cb,
|
||||||
.error = request_done,
|
.error = request_done,
|
||||||
};
|
};
|
||||||
|
int ret = UCLIENT_ERROR_CONNECT;
|
||||||
|
|
||||||
struct uclient *cl = uclient_new(url, NULL, &cb);
|
struct uclient *cl = uclient_new(url, NULL, &cb);
|
||||||
if (!cl)
|
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))
|
if (uclient_request(cl))
|
||||||
goto err;
|
goto err;
|
||||||
uloop_run();
|
uloop_run();
|
||||||
uclient_free(cl);
|
|
||||||
|
|
||||||
if (!d.err_code && d.length >= 0 && d.downloaded != d.length)
|
if (!d.err_code && d.length >= 0 && d.downloaded != d.length) {
|
||||||
return UCLIENT_ERROR_SIZE_MISMATCH;
|
ret = UCLIENT_ERROR_SIZE_MISMATCH;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
return d.err_code;
|
ret = d.err_code;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (cl)
|
if (cl)
|
||||||
uclient_free(cl);
|
uclient_free(cl);
|
||||||
|
|
||||||
return UCLIENT_ERROR_CONNECT;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue