Re: [PATCH v7 03/10] pkt-line: add packet_write_fmt_gently()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 8, 2016 at 11:21 AM,  <larsxschneider@xxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]