From: Austin Clements <amdragon@MIT.EDU>
To: David Edmondson <dme@dme.org>
Cc: notmuch@notmuchmail.org
Subject: Re: [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return.
Date: Thu, 22 Dec 2011 15:15:53 -0500 [thread overview]
Message-ID: <20111222201553.GK10376@mit.edu> (raw)
In-Reply-To: <cuny5u4v260.fsf@hotblack-desiato.hh.sledj.net>
Quoth David Edmondson on Dec 22 at 7:25 pm:
> 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. */;
> }
Maybe I missed something, but what's wrong with using a standard write
loop (like j4ni suggested on IRC)? In my mind this isn't about
appeasing the compiler; the compiler is pointing out a real bug.
Patch coming in a moment...
I'm not sure what to do about the specific case of fwrite, though
judging by
http://sourceware.org/bugzilla/show_bug.cgi?id=11959
I'm not the only person who thinks that fwrite being
warn_unused_result is odd.
next prev parent reply other threads:[~2011-12-22 20:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 21:38 [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return David Edmondson
2011-12-22 7:03 ` Austin Clements
2011-12-22 7:21 ` David Edmondson
2011-12-22 19:03 ` Austin Clements
2011-12-22 19:25 ` David Edmondson
2011-12-22 20:04 ` David Edmondson
2011-12-22 20:15 ` Austin Clements [this message]
2011-12-22 20:15 ` [PATCH] Properly handle short writes in sigint handlers Austin Clements
2011-12-23 8:10 ` David Edmondson
2011-12-23 12:30 ` Tomi Ollila
2011-12-25 0:38 ` Austin Clements
2011-12-25 0:38 ` Austin Clements
2011-12-23 19:10 ` Dmitry Kurochkin
2012-01-10 11:13 ` David Bremner
2012-01-11 13:04 ` Tomi Ollila
2011-12-22 9:32 ` [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return Dmitry Kurochkin
2011-12-22 11:24 ` David Edmondson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111222201553.GK10376@mit.edu \
--to=amdragon@mit.edu \
--cc=dme@dme.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).