Re: [PATCH v7 03/10] pkt-line: add packet_write_fmt_gently()
- From
Lars Schneider <larsxschneider@gmail.com>
- Date
- Sep 11, 2016, 11:36 UTC
- Message-ID
- <714C1346-6A7D-4A8B-AAA2-BA936EB6B739@gmail.com>
- In-Reply-To
- <CAGZ79kY0GaWuuh_MzKL6FZ7KWF2Kwhfh9qnEYd-qX8VDQWNmCQ@mail.gmail.com>
Show 19 quoted lines
> On 08 Sep 2016, at 23:18, Stefan Beller <sbeller@google.com> wrote:
>
> On Thu, Sep 8, 2016 at 11:21 AM, <larsxschneider@gmail.com> 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?Yes, might be better. I wasn't sure because the check_pipe is not public.
Where would you declare check_pipe? In cache.h? Maybe it would be more suitable to move check_pipe to run-command.h/c?
Show 19 quoted lines
>> + 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.Of course!!
Thank you, Lars