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

Re: [PATCH v3 1/3] Introduce die_errno() that appends strerror(errno) to die()

From
Andreas Ericsson <ae@op5.se>
Date
Jun 9, 2009, 09:29 UTC
Message-ID
<4A2E2B8F.3020005@op5.se>
In-Reply-To
<20090609085328.GA25721@coredump.intra.peff.net>
Jeff King wrote:
Show 22 quoted lines
> On Tue, Jun 09, 2009 at 10:22:30AM +0200, Thomas Rast wrote:
> 
>>> Aren't you assuming that strerror(errno) has no '%'-signs here, which is
>>> what kicked off the whole discussion?
>> True, of course.  Hrm.
>>
>> So do we go back to v2 (for 1/3) and ask future callers to never use
>> custom formats with die_errno, or should I write a version that
>> doubles the % characters while tacking the error message onto the
>> format?
> 
> Personally, I think it is fine to assume that the format and arguments
> to die(), die_errno(), and to the die_routine() are all
> printf-compatible. That is how it has always been until now, and I don't
> see any callers who would want to change that.
> 
> This is all internal to git.  It's not as if we are talking about a
> library being called by arbitrary code, and we want to leave doors open
> for arbitrary clients. libgit2 would probably take a different approach
> (though I imagine their general strategy is never to die(), but to
> always return an error condition, anyway).
> 

Yup. libgit2 sets an internal git_errno variable and returns an error code for each error it encounters, and we're referring callers to regular "errno" to find out more about *why* a particular git_errno condition was encountered.

We might want to give applications an easy way to die with a sensible error message, but that's so far in the future that it's not worth bothering with.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
Previous: Jeff KingNext: Thomas Rast
Message 8 of 14 in “die_errno()”
  1. 0/3 die_errno()Thomas Rast, Jun 8, 2009
  2. 1/3 Introduce die_errno() that appends strerror(errno) to die()Thomas Rast, Jun 8, 2009
  3. 2/3 Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast, Jun 8, 2009
  4. 3/3 Use die_errno() instead of die() when checking syscallsThomas Rast, Jun 8, 2009
  5. Jeff KingJun 8, 2009
  6. Thomas RastJun 9, 2009
  7. Jeff KingJun 9, 2009
  8. Andreas EricssonJun 9, 2009
  9. 0/4 die_errno()Thomas Rast, Jun 27, 2009
  10. 1/4 Introduce die_errno() that appends strerror(errno) to die()Thomas Rast, Jun 27, 2009
  11. 2/4 die_errno(): double % in strerror() output just in caseThomas Rast, Jun 27, 2009
  12. 3/4 Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast, Jun 27, 2009
  13. 4/4 Use die_errno() instead of die() when checking syscallsThomas Rast, Jun 27, 2009
  14. Junio C HamanoJun 27, 2009

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.