Re: [PATCH v7 03/10] pkt-line: add packet_write_fmt_gently()
From: Stefan Beller <hidden>
Date: 2016-09-08 21:18:44
On Thu, Sep 8, 2016 at 11:21 AM, [off-list ref] wrote:
+static int packet_write_fmt_1(int fd, int gently,
+ const char *fmt, va_list args)
+{
+ struct strbuf buf = STRBUF_INIT;
+ size_t count;
+
+ format_packet(&buf, fmt, args);
+ count = write_in_full(fd, buf.buf, buf.len);
+ if (count == buf.len)
+ return 0;
+
+ if (!gently) {
call check_pipe from write_or_die here instead of
reproducing that function?
+ if (errno == EPIPE) {
+ if (in_async())
+ async_exit(141);
+
+ signal(SIGPIPE, SIG_DFL);
+ raise(SIGPIPE);
+ /* Should never happen, but just in case... */
+ exit(141);
+ }
+ die_errno("packet write error");
+ }
+ error("packet write failed");
+ return -1;
I think the more idiomatic way is to
return error(...);
as error always return -1.