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

Re: [PATCH v2 2/3] Convert existing die(..., strerror(errno)) to die_errno()

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 6, 2009, 20:31 UTC
Message-ID
<200906062231.24184.j6t@kdbg.org>
In-Reply-To
<095b4af080c11b4ad3fcfaefc9cdf49d383cb714.1244299302.git.trast@student.ethz.ch>
On Samstag, 6. Juni 2009, Thomas Rast wrote:
Show 5 quoted lines
> Change calls to die(..., strerror(errno)) to use the new die_errno().
>
> In the process, also make slight style adjustments: at least state
> _something_ about the function that failed (instead of just printing
> the pathname), and put paths in single quotes.
Show 9 quoted lines
> @@ -428,8 +428,8 @@ static void merge_name(const char *remote, struct
> strbuf *msg)
>
>  		fp = fopen(git_path("FETCH_HEAD"), "r");
>  		if (!fp)
> -			die("could not open %s for reading: %s",
> -				git_path("FETCH_HEAD"), strerror(errno));
> +			die_errno("could not open %s for reading",
> +				  git_path("FETCH_HEAD"));

You said you added quotes, but you didn't do that here and in quite a few more other cases.

IMHO, the quotes are not an improvement anyway, but that's really only my personal taste.

Show 8 quoted lines
> --- a/connect.c
> +++ b/connect.c
> @@ -256,7 +256,7 @@ static int git_tcp_connect_sock(char *host, int flags)
>  	freeaddrinfo(ai0);
>
>  	if (sockfd < 0)
> -		die("unable to connect a socket (%s)", strerror(saved_errno));
> +		die_errno("unable to connect a socket");

You cannot convert this: We want strerror(saved_errno), but die_errno would print strerror(errno).

Show 6 quoted lines
> @@ -345,7 +345,7 @@ static int git_tcp_connect_sock(char *host, int flags)
>  	}
>
>  	if (sockfd < 0)
> -		die("unable to connect a socket (%s)", strerror(saved_errno));
> +		die_errno("unable to connect a socket");
Same here.
-- Hannes
Previous: Thomas RastNext: Johannes Sixt
Message 16 of 28 in “add strerror(errno) to die() calls where applicable”
  1. add strerror(errno) to die() calls where applicableThomas Rast, Jun 2, 2009
  2. Jeff KingJun 3, 2009
  3. diesys calls die and also reports strerror(errno)Alexander Potashev, Jun 4, 2009
  4. Jeff KingJun 4, 2009
  5. Junio C HamanoJun 4, 2009
  6. Johannes SixtJun 5, 2009
  7. Junio C HamanoJun 5, 2009
  8. Jeff KingJun 6, 2009
  9. Thomas RastJun 6, 2009
  10. 0/3 Thomas Rast <trast@student.ethz.ch>Thomas Rast, Jun 6, 2009
  11. 1/3 Introduce die_errno() that appends strerror(errno) to die()Thomas Rast, Jun 6, 2009
  12. 2/3 Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast, Jun 6, 2009
  13. 3/3 Use die_errno() instead of die() when checking syscallsThomas Rast, Jun 6, 2009
  14. Johannes SixtJun 6, 2009
  15. Thomas RastJun 6, 2009
  16. Johannes SixtJun 6, 2009
  17. Johannes SixtJun 6, 2009
  18. Thomas RastJun 6, 2009
  19. Johannes SixtJun 6, 2009
  20. Jeff KingJun 6, 2009
  21. Jeff KingJun 6, 2009
  22. Alexander PotashevJun 7, 2009
  23. Junio C HamanoJun 7, 2009
  24. Jeff KingJun 8, 2009
  25. Alexander PotashevJun 8, 2009
  26. Jeff KingJun 8, 2009
  27. Alexander PotashevJun 4, 2009
  28. Jeff KingJun 4, 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.