From 1054af7d04aef64378d69a0496b45cdbf6a0bef2 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 16 Jul 2014 11:01:18 -0700 Subject: wrapper.c: remove/unlink_or_warn: simplify, treat ENOENT as success Simplify the function warn_if_unremovable slightly. Additionally, change behaviour slightly. If we failed to remove the object because the object does not exist, we can still return success back to the caller since none of the callers depend on "fail if the file did not exist". Signed-off-by: Ronnie Sahlberg Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- wrapper.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'wrapper.c') diff --git a/wrapper.c b/wrapper.c index 5b77d2a1ae..8d4be66e66 100644 --- a/wrapper.c +++ b/wrapper.c @@ -466,14 +466,12 @@ int xmkstemp_mode(char *template, int mode) static int warn_if_unremovable(const char *op, const char *file, int rc) { - if (rc < 0) { - int err = errno; - if (ENOENT != err) { - warning("unable to %s %s: %s", - op, file, strerror(errno)); - errno = err; - } - } + int err; + if (!rc || errno == ENOENT) + return 0; + err = errno; + warning("unable to %s %s: %s", op, file, strerror(errno)); + errno = err; return rc; } -- cgit v1.2.3