Re: [PATCH v6 4/7] pack-bitmap.c: don't ignore ENOENT silently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 11 2022, Teng Long wrote:

> When finished call git_open(), instead of ignoring ENOENT silently
> and return error_errno(_("cannot stat...")), it's better to check
> the ENOENT before then output the warning.

Makes sense, but...

> -	if (fd < 0)
> +	if (fd < 0) {
> +		if (errno != ENOENT)
> +			warning("'%s' cannot open '%s'", strerror(errno), bitmap_name);

This should just be warning_errno("cannot open '%s'", bitmap_name),
unless I'm missing something...


> +		free(bitmap_name);
>  		return -1;
> +	}
> +	free(bitmap_name);
>  
>  	if (fstat(fd, &st)) {
>  		close(fd);
> @@ -376,10 +379,14 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
>  
>  	bitmap_name = pack_bitmap_filename(packfile);
>  	fd = git_open(bitmap_name);
> -	free(bitmap_name);
>  
> -	if (fd < 0)
> +	if (fd < 0) {
> +		if (errno != ENOENT)
> +			warning("'%s' cannot open '%s'", strerror(errno), bitmap_name);

...ditto.


> +		free(bitmap_name);
>  		return -1;
> +	}
> +	free(bitmap_name);
>  
>  	if (fstat(fd, &st)) {
>  		close(fd);




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux