Skip to content

Commit ca5c701

Browse files
peffgitster
authored andcommitted
write_or_die: drop write_or_whine_pipe()
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 46ac74b commit ca5c701

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

cache.h

-1
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,6 @@ extern int copy_file(const char *dst, const char *src, int mode);
17401740
extern int copy_file_with_time(const char *dst, const char *src, int mode);
17411741

17421742
extern void write_or_die(int fd, const void *buf, size_t count);
1743-
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
17441743
extern void fsync_or_die(int fd, const char *);
17451744

17461745
extern ssize_t read_in_full(int fd, void *buf, size_t count);

write_or_die.c

-12
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,3 @@ void write_or_die(int fd, const void *buf, size_t count)
8282
die_errno("write error");
8383
}
8484
}
85-
86-
int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
87-
{
88-
if (write_in_full(fd, buf, count) < 0) {
89-
check_pipe(errno);
90-
fprintf(stderr, "%s: write error (%s)\n",
91-
msg, strerror(errno));
92-
return 0;
93-
}
94-
95-
return 1;
96-
}

0 commit comments

Comments
 (0)