Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2010-03-26 18:25:32 +0300
committerJunio C Hamano <gitster@pobox.com>2010-03-28 20:52:59 +0400
commit10e13ec8ed36019d131d27cd9fe2e8cc0f99b896 (patch)
treec39ebffe0c0eb75797c3d30754ecdfb13a188bb9 /wrapper.c
parent5e4f61474202122f376b16181b760f390623bf4e (diff)
Generalise the unlink_or_warn function
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>
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/wrapper.c b/wrapper.c
index 9c71b21242..0bbff56e2c 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -311,18 +311,20 @@ int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
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));
+}