Re: [PATCH] compile-i386.c: don't ignore return value of write(2)

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

 



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@xxxxxxxxxxxxxxxxxxx>
> 
> 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



--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux