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

Re: [RFC] Cleaning up die() error messages

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Oct 10, 2005, 20:14 UTC
Message-ID
<Pine.LNX.4.63.0510101603520.23242@iabervon.org>
In-Reply-To
<20051010105008.GB30202@gentoo.org>
On Mon, 10 Oct 2005, Elfyn McBratney wrote:
Show 20 quoted lines
> 	[C sources]
> 	static char *prog;
> 	..
> 	static inline void set_prog_name (char *argv0)
> 	{
> 		prog = strrchr(argv0, '/');
> 		if (prog)
> 			prog++;
> 		else
> 			prog = argv0;
> 	}
> 	..
> 	int main (int argc, char **argv)
> 	{
> 		set_prog_name(argv[0]);
> 		..
> 		if (!do_bar())
> 			die("%s: do_bar() failed", prog);
> 		..
> 	}

Just put set_prog_name() next to die(), and have die() write "prog: " at the beginning if set_prog_name() got called. Assuming it's useful at all to show the name of the program, it's not going to be less useful if the error is actually found in a library function called by the program.

	-Daniel
*This .sig left intentionally blank*
Previous: Matthias UrlichsNext: Alex Riesen
Message 11 of 13 in “[RFC] Cleaning up die() error messages”
  1. Elfyn McBratneyOct 10, 2005
  2. Junio C HamanoOct 10, 2005
  3. Matthias UrlichsOct 11, 2005
  4. H. Peter AnvinOct 11, 2005
  5. Matthias UrlichsOct 12, 2005
  6. H. Peter AnvinOct 12, 2005
  7. Junio C HamanoOct 12, 2005
  8. H. Peter AnvinOct 12, 2005
  9. Junio C HamanoOct 12, 2005
  10. Matthias UrlichsOct 12, 2005
  11. Daniel BarkalowOct 10, 2005
  12. Alex RiesenOct 11, 2005
  13. H. Peter AnvinOct 11, 2005

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.