unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
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 14:03:05 -0500	[thread overview]
Message-ID: <20111222190305.GA324@mit.edu> (raw)
In-Reply-To: <cunfwgdvzpy.fsf@hotblack-desiato.hh.sledj.net>

Quoth David Edmondson on Dec 22 at  7:21 am:
> On Thu, 22 Dec 2011 02:03:45 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
> > I must admit I haven't been following the warnings problem very
> > closely, but perhaps we shouldn't be ignoring these return codes?
> 
> 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.

fwrite's a little trickier, since it will only short-write on an
error, so to me it seems perfectly legitimate to ignore the result if
you don't care about errors.

I don't seem to have whatever glibc version the buildbot does that
marks these warn_unused_result, but I can reproduce it by adding

__attribute__((warn_unused_result))
ssize_t write(int fd, const void *buf, size_t count);
__attribute__((warn_unused_result))
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);

to notmuch-client.h.  Testing with these, if I add any form of result
checking, even if it does nothing in most cases, GCC is quiet.

  reply	other threads:[~2011-12-22 19:02 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 [this message]
2011-12-22 19:25       ` David Edmondson
2011-12-22 20:04         ` David Edmondson
2011-12-22 20:15         ` Austin Clements
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=20111222190305.GA324@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).