qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] replay: Fix build with -Werror=unused-result


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] replay: Fix build with -Werror=unused-result
Date: Wed, 21 Sep 2016 08:24:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

"Pavel Dovgalyuk" <address@hidden> writes:

>> From: Felipe Franciosi [mailto:address@hidden
>> If compiling with -Werror=unused-result, replay-internal.c won't build
>> due to a call to fwrite() where the returned value is ignored. A simple
>> cast to (void) is not sufficient on recent GCCs, so this fixes it.
>> 
>> Signed-off-by: Felipe Franciosi <address@hidden>
>> ---
>>  replay/replay-internal.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/replay/replay-internal.c b/replay/replay-internal.c
>> index 5835e8d..6978d76 100644
>> --- a/replay/replay-internal.c
>> +++ b/replay/replay-internal.c
>> @@ -65,7 +65,7 @@ void replay_put_array(const uint8_t *buf, size_t size)
>>  {
>>      if (replay_file) {
>>          replay_put_dword(size);
>> -        fwrite(buf, 1, size, replay_file);
>> +        (void)(fwrite(buf, 1, size, replay_file)+1);
>>      }
>>  }
>
> This looks very weird.
> I think it would be better to check the return value and stop
> the simulation in case of error.

Ignoring errors is wrong more often than not.  Whether it's wrong in
this case I can't say.  What I can say is 1. the commit message needs to
explain *why* the error can be ignored, and 2. the way you ignore the
error is scandalously ugly :)  You say gcc doesn't honor the traditional
cast to void anymore.  What's the exact error message you see?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]