write_or_die: drop write_or_whine_pipe()
authorJeff King <peff@peff.net>
Wed, 3 Aug 2016 23:01:42 +0000 (19:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Aug 2016 16:28:17 +0000 (09:28 -0700)
This function has no callers, and is not likely to gain any
because it's confusing to use.

It unconditionally complains to stderr, but _doesn't_ die.
Yet any caller which wants a "gentle" write would generally
want to suppress the error message, because presumably
they're going to write a better one, and/or try the
operation again.

And the check_pipe() call leads to confusing behaviors. It
means we die for EPIPE, but not for other errors, which is
confusing and pointless.

On top of all that, it has unusual error return semantics,
which makes it easy for callers to get it wrong.

Let's drop the function, and if somebody ever needs to
resurrect something like it, they can fix these warts.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
write_or_die.c
diff --git a/cache.h b/cache.h
index b5f76a4cf4b1599f024f14553dd8c99a63abf77c..388591157cf7bd25c8b6dd24602bc28df8a4d511 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1740,7 +1740,6 @@ extern int copy_file(const char *dst, const char *src, int mode);
 extern int copy_file_with_time(const char *dst, const char *src, int mode);
 
 extern void write_or_die(int fd, const void *buf, size_t count);
-extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
 extern void fsync_or_die(int fd, const char *);
 
 extern ssize_t read_in_full(int fd, void *buf, size_t count);
index 981687945a761a67f11f651eef78c49621df2d59..073443247a6d56ddd8448aafce854a4b5513e605 100644 (file)
@@ -82,15 +82,3 @@ void write_or_die(int fd, const void *buf, size_t count)
                die_errno("write error");
        }
 }
-
-int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
-{
-       if (write_in_full(fd, buf, count) < 0) {
-               check_pipe(errno);
-               fprintf(stderr, "%s: write error (%s)\n",
-                       msg, strerror(errno));
-               return 0;
-       }
-
-       return 1;
-}