Re: [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return.

Subject: Re: [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return.

Date: Thu, 22 Dec 2011 19:25:59 +0000

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: David Edmondson


On Thu, 22 Dec 2011 14:03:05 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
> > In general I agree, but what would we do if writing an error message to
> > stderr fails?
> 
> This was discussed on IRC, but calls to write(2) should never be bare.
> I believe it's marked warn_unused_result not because libc is so
> concerned with people checking for error returns (otherwise all sorts
> of things would be marked warn_unused_result) but because even a
> successful write can be a short write.  Hence, not checking the result
> is a bug, even if you don't care about errors.

As I said, the principle is sound. What would do in this specific case?

static void
handle_sigint (unused (int sig))
{
    static char msg[] = "Stopping...         \n";

    write(2, msg, sizeof(msg)-1);
    interrupted = 1;
}

Just this?

     if (write(2, msg, sizeof(msg)-1) {
        /* Appease the compiler. */;
     }
part-000.sig (application/pgp-signature)

Thread: