From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Christopher Li <sparse@chrisli.org>,
Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH] compile-i386.c: don't ignore return value of write(2)
Date: Tue, 14 Oct 2014 11:13:47 +0100 [thread overview]
Message-ID: <543CF75B.1020507@ramsay1.demon.co.uk> (raw)
In-Reply-To: <20141014031428.GA1009@thin>
On 14/10/14 04:14, Josh Triplett wrote:
> On Tue, Oct 14, 2014 at 12:03:31AM +0100, Ramsay Jones wrote:
>>
>> Some versions of gcc (e.g. v4.8.2) complain about ignoring the return
>> value of a call to the write(2) system call, since the system header
>> files have marked its declaration with the warn_unused_result attribute.
>>
>> In order to suppress the compiler warning, check the return value from
>> 'write' and, if it indicates an error (a negative return value), exit
>> the process using 'die' to display an error message. Replace a second
>> call to 'write', which does not provoke a compiler warning, with similar
>> code for consistency.
>>
>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>
> That isn't the only way write() can fail; it can also do a partial
> write, in which case you need to loop and write the rest. You might
> consider adding an xwrite() function which includes that logic.
I did consider doing exactly that, but I wanted a _minimal_ fix for a
program that is basically unmaintained. However, if Chris would like
such a patch, I will happily provide one! ;-)
> (Alternatively, you could use standard C IO, which doesn't have that
> problem.)
See the very first version of this patch. :-D (I still slightly prefer
the first patch, very closely followed by the second version; this is
the third attempt).
ATB,
Ramsay Jones
prev parent reply other threads:[~2014-10-14 10:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-13 23:03 [PATCH] compile-i386.c: don't ignore return value of write(2) Ramsay Jones
2014-10-14 3:14 ` Josh Triplett
2014-10-14 10:13 ` Ramsay Jones [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=543CF75B.1020507@ramsay1.demon.co.uk \
--to=ramsay@ramsay1.demon.co.uk \
--cc=josh@joshtriplett.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.