git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Compile warnings

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 14, 2011, 20:36 UTC
Message-ID
<7v39dqjvbj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<op.v4xyekju0aolir@keputer>
"Frans Klaver" <fransklaver@gmail.com> writes:
Show 5 quoted lines
> 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).

Previous: Frans Klaver
Message 4 of 4 in “Compile warnings”
  1. Frans KlaverNov 14, 2011
  2. Ævar Arnfjörð BjarmasonNov 14, 2011
  3. Frans KlaverNov 14, 2011
  4. Junio C HamanoNov 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.