pkt-line: drop safe_write function
This is just write_or_die by another name. The one distinction is that write_or_die will treat EPIPE specially by suppressing error messages. That's fine, as we die by SIGPIPE anyway (and in the off chance that it is disabled, write_or_die will simulate it). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e148542870
commit
cdf4fb8e33
21
pkt-line.c
21
pkt-line.c
@ -46,23 +46,6 @@ static void packet_trace(const char *buf, unsigned int len, int write)
|
||||
strbuf_release(&out);
|
||||
}
|
||||
|
||||
ssize_t safe_write(int fd, const void *buf, ssize_t n)
|
||||
{
|
||||
ssize_t nn = n;
|
||||
while (n) {
|
||||
int ret = xwrite(fd, buf, n);
|
||||
if (ret > 0) {
|
||||
buf = (char *) buf + ret;
|
||||
n -= ret;
|
||||
continue;
|
||||
}
|
||||
if (!ret)
|
||||
die("write error (disk full?)");
|
||||
die_errno("write error");
|
||||
}
|
||||
return nn;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we buffered things up above (we don't, but we should),
|
||||
* we'd flush it here
|
||||
@ -70,7 +53,7 @@ ssize_t safe_write(int fd, const void *buf, ssize_t n)
|
||||
void packet_flush(int fd)
|
||||
{
|
||||
packet_trace("0000", 4, 1);
|
||||
safe_write(fd, "0000", 4);
|
||||
write_or_die(fd, "0000", 4);
|
||||
}
|
||||
|
||||
void packet_buf_flush(struct strbuf *buf)
|
||||
@ -106,7 +89,7 @@ void packet_write(int fd, const char *fmt, ...)
|
||||
va_start(args, fmt);
|
||||
n = format_packet(fmt, args);
|
||||
va_end(args);
|
||||
safe_write(fd, buffer, n);
|
||||
write_or_die(fd, buffer, n);
|
||||
}
|
||||
|
||||
void packet_buf_write(struct strbuf *buf, const char *fmt, ...)
|
||||
|
Reference in New Issue
Block a user