[PATCH v6 4/7] pack-bitmap.c: don't ignore ENOENT silently
- From
Teng Long <dyroneteng@gmail.com>
- Date
- Jul 11, 2022, 12:44 UTC
- Message-ID
- <009cc49a18f2846c24256102e07437894ac16908.1657540174.git.dyroneteng@gmail.com>
- In-Reply-To
- <cover.1657540174.git.dyroneteng@gmail.com>
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.
Signed-off-by: Teng Long <dyroneteng@gmail.com> --- pack-bitmap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/pack-bitmap.c b/pack-bitmap.c index 7d8cc063fc..319eb721d8 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -317,10 +317,13 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, char *bitmap_name = midx_bitmap_filename(midx); int 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); + 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); + free(bitmap_name); return -1; + } + free(bitmap_name); if (fstat(fd, &st)) { close(fd);
-- 2.35.0.rc0.676.g60105b7097.dirty