From 66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 25 Aug 2021 22:16:46 +0200 Subject: use xopen() to handle fatal open(2) failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add and apply a semantic patch for using xopen() instead of calling open(2) and die() or die_errno() explicitly. This makes the error messages more consistent and shortens the code. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- builtin/hash-object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'builtin/hash-object.c') diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 640ef4ded5..2e6e2ddd0c 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -53,9 +53,7 @@ static void hash_object(const char *path, const char *type, const char *vpath, unsigned flags, int literally) { int fd; - fd = open(path, O_RDONLY); - if (fd < 0) - die_errno("Cannot open '%s'", path); + fd = xopen(path, O_RDONLY); hash_fd(fd, type, vpath, flags, literally); } -- cgit v1.2.3