[pacman-dev] [PATCH 3/5] libalpm: don't use curl's deprecated functions

Eli Schwartz eschwartz at archlinux.org
Fri Jan 1 18:57:03 UTC 2021


On 1/1/21 11:57 AM, morganamilo via pacman-dev wrote:
> ---
>   lib/libalpm/dload.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
> index d3636e18..df5e8be7 100644
> --- a/lib/libalpm/dload.c
> +++ b/lib/libalpm/dload.c
> @@ -391,7 +391,8 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
>   	CURLcode curlerr;
>   	char *effective_url;
>   	long timecond;
> -	double remote_size, bytes_dl = 0;
> +	curl_off_t remote_size;
> +	curl_off_t bytes_dl = 0;
>   	long remote_time = -1;
>   	struct stat st;
>   	char hostname[HOSTNAME_SIZE];
> @@ -476,8 +477,8 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
>   
>   	/* retrieve info about the state of the transfer */
>   	curl_easy_getinfo(curl, CURLINFO_FILETIME, &remote_time);
> -	curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &remote_size);
> -	curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &bytes_dl);

Originally implemented in dload.c in commit 
96e458b705eda4ddff7d6ec890cf1daf898e9186 in 2011.

> +	curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &remote_size);
> +	curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &bytes_dl);

AVAILABILITY

Added in 7.55.0

A change like this MUST bump the minimum required dependency version. 
Admittedly a version from mid-2017 is not hard to get, but on the other 
hand, it's not really deprecated... just an older style.

I don't have a strong opinion on whether or not to do all this. But 
please resubmit with changes to meson.build too.

>   	curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &timecond);
>   	curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
>   
> @@ -539,7 +540,7 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
>   
>   	/* time condition was met and we didn't download anything. we need to
>   	 * clean up the 0 byte .part file that's left behind. */
> -	if(timecond == 1 && DOUBLE_EQ(bytes_dl, 0)) {
> +	if(timecond == 1 && bytes_dl == 0) {
>   		_alpm_log(handle, ALPM_LOG_DEBUG, "%s: file met time condition\n",
>   			payload->remote_name);
>   		ret = 1;
> @@ -550,8 +551,8 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
>   	/* remote_size isn't necessarily the full size of the file, just what the
>   	 * server reported as remaining to download. compare it to what curl reported
>   	 * as actually being transferred during curl_easy_perform() */
> -	if(!DOUBLE_EQ(remote_size, -1) && !DOUBLE_EQ(bytes_dl, -1) &&
> -			!DOUBLE_EQ(bytes_dl, remote_size)) {
> +	if(remote_size != -1 && bytes_dl != -1 &&
> +			bytes_dl != remote_size) {

Given you're removing all users of the util.h DOUBLE_EQ macro, you could 
be dropping the macro at the same time.

>   		_alpm_log(handle, ALPM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
>   				payload->remote_name, (intmax_t)bytes_dl, (intmax_t)remote_size);
>   		GOTO_ERR(handle, ALPM_ERR_RETRIEVE, cleanup);
> 


-- 
Eli Schwartz
Bug Wrangler and Trusted User

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20210101/9a557d3a/attachment.sig>


More information about the pacman-dev mailing list