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

Re: [PATCH] clean: use warning_errno() when appropriate

From
Jeff King <peff@peff.net>
Date
Feb 13, 2017, 22:22 UTC
Message-ID
<20170213222210.dtfnxbbi77tsx4a6@sigill.intra.peff.net>
In-Reply-To
<xmqqy3x9bvvm.fsf@gitster.mtv.corp.google.com>
On Mon, Feb 13, 2017 at 01:53:33PM -0800, Junio C Hamano wrote:
Show 14 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > IOW, I think this may be a case where we should be optimizing for
> > programmer time (fewer lines of code, and one less thing to worry about
> > in the callers) versus squeezing out every instruction.
> 
> Fair enough.
> 
> Unless we do the save_errno dance in all the helper functions we
> commonly use to safely stash away errno as necessary and tell
> developers that they can depend on it, the code in the patch that
> began this discussion still needs its own saved_errno dance to be
> safe, though.  I do not have a feeling that we are not there yet,
> even after we teach xmalloc() and its family to do so.

Yeah, I certainly agree that is a potential blocker. Even if it is true today, there's nothing guaranteeing that the quote functions don't grow a new internal detail that violates.

So in that sense doing the errno dance as close to the caller who cares is the most _obvious_ thing, even if it isn't the shortest.

It would be nice if there was a way to annotate a function as errno-safe, and then transitively compute which other functions were errno-safe when they do not call any errno-unsafe function. I don't know if any static analyzers allow that kind of custom annotation, though (and also I wonder whether the cost/benefit of maintaining those annotations would be worth it).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 13 in “clean: use warning_errno() when appropriate”
  1. clean: use warning_errno() when appropriateNguyễn Thái Ngọc Duy, Feb 13, 2017
  2. Junio C HamanoFeb 13, 2017
  3. Jeff KingFeb 13, 2017
  4. Junio C HamanoFeb 13, 2017
  5. Jeff KingFeb 13, 2017
  6. Junio C HamanoFeb 13, 2017
  7. Jeff KingFeb 13, 2017
  8. Junio C HamanoFeb 13, 2017
  9. clean: use warning_errno() when appropriateNguyễn Thái Ngọc Duy, Feb 14, 2017
  10. Junio C HamanoFeb 14, 2017
  11. Duy NguyenFeb 15, 2017
  12. Junio C HamanoFeb 15, 2017
  13. Jeff KingFeb 15, 2017

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.