Re: [PATCH v6 4/7] pack-bitmap.c: don't ignore ENOENT silently
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 11, 2022, 14:38 UTC
- Message-ID
- <220711.86k08j7lyn.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <009cc49a18f2846c24256102e07437894ac16908.1657540174.git.dyroneteng@gmail.com>
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...
Show 17 quoted lines
> + 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.
Show 7 quoted lines
> + free(bitmap_name);
> return -1;
> + }
> + free(bitmap_name);
>
> if (fstat(fd, &st)) {
> close(fd);