git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Compile warnings
@ 2011-11-14 14:55 Frans Klaver
  2011-11-14 16:58 ` Ævar Arnfjörð Bjarmason
  2011-11-14 20:36 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Frans Klaver @ 2011-11-14 14:55 UTC (permalink / raw)
  To: git@vger.kernel.org

Hi,

Every now and then I see an 'unused result' warning come by during  
building. What is the general attitude towards these warnings? Remove them  
(by properly checking)? Or leave them be as a kind of documentation -- we  
know we're ignoring the info, but it's good to be reminded?

Thanks,
Frans

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile warnings
  2011-11-14 14:55 Compile warnings Frans Klaver
@ 2011-11-14 16:58 ` Ævar Arnfjörð Bjarmason
  2011-11-14 21:55   ` Frans Klaver
  2011-11-14 20:36 ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2011-11-14 16:58 UTC (permalink / raw)
  To: Frans Klaver; +Cc: git@vger.kernel.org

On Mon, Nov 14, 2011 at 15:55, Frans Klaver <fransklaver@gmail.com> wrote:
> Every now and then I see an 'unused result' warning come by during building.
> What is the general attitude towards these warnings? Remove them (by
> properly checking)? Or leave them be as a kind of documentation -- we know
> we're ignoring the info, but it's good to be reminded?

Under what OS / version and compiler / version and what's the warning?
Paste the full warning(s) you get verbatim.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile warnings
  2011-11-14 14:55 Compile warnings Frans Klaver
  2011-11-14 16:58 ` Ævar Arnfjörð Bjarmason
@ 2011-11-14 20:36 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2011-11-14 20:36 UTC (permalink / raw)
  To: Frans Klaver; +Cc: git@vger.kernel.org

"Frans Klaver" <fransklaver@gmail.com> writes:

> Every now and then I see an 'unused result' warning come by during
> building. What is the general attitude towards these warnings? Remove
> them  (by properly checking)? Or leave them be as a kind of
> documentation -- we  know we're ignoring the info, but it's good to be
> reminded?

A callsite of a function whose return value is better checked should be
checked (e.g. not checking return from close(2) or write(2) in a non-error
codepath), but there is no strong mechanical "General attitude".

Sprinkling (void) that casts the return values all over the place makes
our code illegible, and we do not prefer it as a solution. A function
that returns a value that is useful for some callers but can be safely
ignored by others is sometimes an indication of a poor API, and for our
own code, we tend to prefer designing the API to pass optional pointer
to return value from callers that do want to use the return value (and
others that do not care about the return value pass NULL).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile warnings
  2011-11-14 16:58 ` Ævar Arnfjörð Bjarmason
@ 2011-11-14 21:55   ` Frans Klaver
  0 siblings, 0 replies; 4+ messages in thread
From: Frans Klaver @ 2011-11-14 21:55 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git@vger.kernel.org, Junio C Hamano

On Mon, 14 Nov 2011 17:58:20 +0100, Ævar Arnfjörð Bjarmason  
<avarab@gmail.com> wrote:

> On Mon, Nov 14, 2011 at 15:55, Frans Klaver <fransklaver@gmail.com>  
> wrote:
>> Every now and then I see an 'unused result' warning come by during  
>> building.
>> What is the general attitude towards these warnings? Remove them (by
>> properly checking)? Or leave them be as a kind of documentation -- we  
>> know
>> we're ignoring the info, but it's good to be reminded?
>
> Under what OS / version and compiler / version and what's the warning?
> Paste the full warning(s) you get verbatim.

This question was triggered by

     warning: ignoring return value of ‘fwrite’, declared with attribute  
warn_unused_result

appearing in diff.c, graph.c, grep.c and several others. I'm using gentoo  
linux, gcc 4.5.3.

So the specific question would be, do these fwrites need to be checked?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-14 21:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 14:55 Compile warnings Frans Klaver
2011-11-14 16:58 ` Ævar Arnfjörð Bjarmason
2011-11-14 21:55   ` Frans Klaver
2011-11-14 20:36 ` Junio C Hamano

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 NNTP newsgroup(s).