summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e4f614)
raw | patch | inline | side by side (parent: 5e4f614)
author | Peter Collingbourne <peter@pcc.me.uk> | |
Fri, 26 Mar 2010 15:25:32 +0000 (15:25 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 28 Mar 2010 16:52:59 +0000 (09:52 -0700) |
This patch moves the warning code of the unlink_or_warn function into
a separate function named warn_if_unremovable so that it may be reused.
Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
a separate function named warn_if_unremovable so that it may be reused.
Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wrapper.c | patch | blob | history |
diff --git a/wrapper.c b/wrapper.c
index 9c71b21242773f52ca560d7e5e5e52123674d334..0bbff56e2c38651b10551d17caeed84e0cc250c8 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
}
-int unlink_or_warn(const char *file)
+static int warn_if_unremovable(const char *op, const char *file, int rc)
{
- int rc = unlink(file);
-
if (rc < 0) {
int err = errno;
if (ENOENT != err) {
- warning("unable to unlink %s: %s",
- file, strerror(errno));
+ warning("unable to %s %s: %s",
+ op, file, strerror(errno));
errno = err;
}
}
return rc;
}
+int unlink_or_warn(const char *file)
+{
+ return warn_if_unremovable("unlink", file, unlink(file));
+}