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

Patch recommendation for replace invoke of error() to that of error_errno()

From
牛牛旭 <niuxu16@nudt.edu.cn>
Date
Jan 5, 2018, 03:24 UTC
Message-ID
<950adae.6741.160c458ce64.Coremail.niuxu16@nudt.edu.cn>
Our team researches on consistent update of Git during evolution. And we have figured out several spots that may be missed. 
By mining historical patches, we suggest that invokes of error(..., strerror(errno)) should be replaced with that of error_errno(). One example for recommendation and corresponding patch are listed as follows. 
One example of missed spot:
1  int cmd_fetch__tool(int argc, const char **argv, const char 
  *prefix)
2  {
....
31  filename = git_path_fetch_head();
32  fp = fopen(filename, "a");
33  if (!fp)
34  return error("cannot open %s: %s", filename, strerror(errno));
....
  }

One example of historical patch: 1 if (!strcmp(*paths, "-")) 2 in = stdin; 3 else 4 in = fopen(*paths, "r"); 5 6 if (!in) 7 - return error(_("could not open '%s' for reading: %s"), 8 - *paths, strerror(errno)); 9 + return error_errno(_("could not open '%s' for reading"), 10 + *paths); 11 12 mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1); 13 14 out = fopen(mail, "w"); 15 if (!out) 16 - return error(_("could not open '%s' for writing: %s"), 17 - mail, strerror(errno)); 18 + return error_errno(_("could not open '%s' for writing"), 19 + mail); 20 21 ret = fn(out, in, keep_cr); 22 23 fclose(out); 24 fclose(in); 25 More recommendations and supporting patches are saved in attachments. It is so kind of you to reply me about the correctness of our suggestions. And thank you for your reading. 

Next: Jeff King
Message 1 of 4 in “Patch recommendation for replace invoke of error() to that of error_errno()”
  1. 牛旭Jan 5, 2018
  2. Jeff KingJan 5, 2018
  3. recommendations for log enhancement牛旭, Jan 28, 2018
  4. Stefan BellerJan 30, 2018

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.