{"thread":{"id":"7665","subject":"[PATCH] entry.c: Use strerror() to print error info when possible","startedAt":"2007-04-15T21:56:19Z","lastAt":"2007-04-15T23:57:09Z","messageCount":5,"participants":["Luiz Fernando N. Capitulino","Junio C Hamano","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"39411","messageId":"20070415185619.3fa90f3a@gnut","threadId":"7665","inReplyTo":null,"subject":"[PATCH] entry.c: Use strerror() to print error info when possible","fromName":"Luiz Fernando N. Capitulino","fromEmail":"lcapitulino@mandriva.com.br","sentAt":"2007-04-15T21:56:19Z","receivedAt":"2007-04-15T21:56:19Z","isPatch":true,"sender":{"key":"lcapitulino@mandriva.com.br","avatar":null},"body":"\nSigned-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>\n---\n entry.c |   11 ++++++-----\n 1 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/entry.c b/entry.c\nindex d72f811..c36c09d 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -19,7 +19,8 @@ static void create_directories(const char *path, struct checkout *state)\n \t\t\t\tif (!stat(buf, &st) && S_ISDIR(st.st_mode))\n \t\t\t\t\tcontinue; /* ok */\n \t\t\t}\n-\t\t\tdie(\"cannot create directory at %s\", buf);\n+\t\t\tdie(\"cannot create directory at %s (%s)\", buf,\n+\t\t\t    strerror(errno));\n \t\t}\n \t}\n \tfree(buf);\n@@ -33,7 +34,7 @@ static void remove_subtree(const char *path)\n \tchar *name;\n \t\n \tif (!dir)\n-\t\tdie(\"cannot opendir %s\", path);\n+\t\tdie(\"cannot opendir %s (%s)\", path, strerror(errno));\n \tstrcpy(pathbuf, path);\n \tname = pathbuf + strlen(path);\n \t*name++ = '/';\n@@ -45,15 +46,15 @@ static void remove_subtree(const char *path)\n \t\t\tcontinue;\n \t\tstrcpy(name, de->d_name);\n \t\tif (lstat(pathbuf, &st))\n-\t\t\tdie(\"cannot lstat %s\", pathbuf);\n+\t\t\tdie(\"cannot lstat %s (%s)\", pathbuf, strerror(errno));\n \t\tif (S_ISDIR(st.st_mode))\n \t\t\tremove_subtree(pathbuf);\n \t\telse if (unlink(pathbuf))\n-\t\t\tdie(\"cannot unlink %s\", pathbuf);\n+\t\t\tdie(\"cannot unlink %s (%s)\", pathbuf, strerror(errno));\n \t}\n \tclosedir(dir);\n \tif (rmdir(path))\n-\t\tdie(\"cannot rmdir %s\", path);\n+\t\tdie(\"cannot rmdir %s (%s)\", path, strerror(errno));\n }\n \n static int create_file(const char *path, unsigned int mode)\n-- \n1.5.1.1.85.geed2-dirty\n"},{"id":"39415","messageId":"7v7isd2qq0.fsf@assigned-by-dhcp.cox.net","threadId":"7665","inReplyTo":"20070415185619.3fa90f3a@gnut","subject":"Re: [PATCH] entry.c: Use strerror() to print error info when possible","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-15T22:54:47Z","receivedAt":"2007-04-15T22:54:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Luiz Fernando N. Capitulino\" <lcapitulino@mandriva.com.br>\nwrites:\n\n> Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>\n> ---\n>  entry.c |   11 ++++++-----\n>  1 files changed, 6 insertions(+), 5 deletions(-)\n>\n> diff --git a/entry.c b/entry.c\n> index d72f811..c36c09d 100644\n> --- a/entry.c\n> +++ b/entry.c\n> @@ -19,7 +19,8 @@ static void create_directories(const char *path, struct checkout *state)\n>  \t\t\t\tif (!stat(buf, &st) && S_ISDIR(st.st_mode))\n>  \t\t\t\t\tcontinue; /* ok */\n>  \t\t\t}\n> -\t\t\tdie(\"cannot create directory at %s\", buf);\n> +\t\t\tdie(\"cannot create directory at %s (%s)\", buf,\n> +\t\t\t    strerror(errno));\n>  \t\t}\n>  \t}\n>  \tfree(buf);\n\nThis hunk is wrong; stat() you see in the context could have\nbeen what failed the last before this die().\n\nI do not think other places you patched do not share the issue.\n"},{"id":"39416","messageId":"20070415230020.GC4417@steel.home","threadId":"7665","inReplyTo":"20070415185619.3fa90f3a@gnut","subject":"Re: [PATCH] entry.c: Use strerror() to print error info when possible","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-15T23:00:20Z","receivedAt":"2007-04-15T23:00:20Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Luiz Fernando N. Capitulino, Sun, Apr 15, 2007 23:56:19 +0200:\n> \n> Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>\n> ---\n>  entry.c |   11 ++++++-----\n>  1 files changed, 6 insertions(+), 5 deletions(-)\n> \n> diff --git a/entry.c b/entry.c\n> index d72f811..c36c09d 100644\n> --- a/entry.c\n> +++ b/entry.c\n> @@ -19,7 +19,8 @@ static void create_directories(const char *path, struct checkout *state)\n>  \t\t\t\tif (!stat(buf, &st) && S_ISDIR(st.st_mode))\n>  \t\t\t\t\tcontinue; /* ok */\n>  \t\t\t}\n> -\t\t\tdie(\"cannot create directory at %s\", buf);\n> +\t\t\tdie(\"cannot create directory at %s (%s)\", buf,\n> +\t\t\t    strerror(errno));\n\nThis errno is not very useful, as it may come from the stat above, and\nyou provided no way to figure out what was the syscall (the mkdir or\nthe stat) which failed. Also, the errnos of unlink or mkdir just above\nthe stat are just lost.\n\nIt is not worse than before, but not very much better either, and\nprobably confusing. I suggest you just leave this one as it is.\n"},{"id":"39429","messageId":"20070415205433.3b475f60@gnut","threadId":"7665","inReplyTo":"7v7isd2qq0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] entry.c: Use strerror() to print error info when possible","fromName":"Luiz Fernando N. Capitulino","fromEmail":"lcapitulino@mandriva.com.br","sentAt":"2007-04-15T23:54:33Z","receivedAt":"2007-04-15T23:54:33Z","isPatch":true,"sender":{"key":"lcapitulino@mandriva.com.br","avatar":null},"body":"Em Sun, 15 Apr 2007 15:54:47 -0700\nJunio C Hamano <junkio@cox.net> escreveu:\n\n| \"Luiz Fernando N. Capitulino\" <lcapitulino@mandriva.com.br>\n| writes:\n| \n| > Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>\n| > ---\n| >  entry.c |   11 ++++++-----\n| >  1 files changed, 6 insertions(+), 5 deletions(-)\n| >\n| > diff --git a/entry.c b/entry.c\n| > index d72f811..c36c09d 100644\n| > --- a/entry.c\n| > +++ b/entry.c\n| > @@ -19,7 +19,8 @@ static void create_directories(const char *path, struct checkout *state)\n| >  \t\t\t\tif (!stat(buf, &st) && S_ISDIR(st.st_mode))\n| >  \t\t\t\t\tcontinue; /* ok */\n| >  \t\t\t}\n| > -\t\t\tdie(\"cannot create directory at %s\", buf);\n| > +\t\t\tdie(\"cannot create directory at %s (%s)\", buf,\n| > +\t\t\t    strerror(errno));\n| >  \t\t}\n| >  \t}\n| >  \tfree(buf);\n| \n| This hunk is wrong; stat() you see in the context could have\n| been what failed the last before this die().\n\n You right, will try to read the code more carefully before\npatching.\n\n| I do not think other places you patched do not share the issue.\n\n Other places seems ok, I'll review and re-send along with other\npatches I'm working on.\n\n Thanks a lot for the feedback.\n"},{"id":"39430","messageId":"20070415205709.27d7e475@gnut","threadId":"7665","inReplyTo":"20070415230020.GC4417@steel.home","subject":"Re: [PATCH] entry.c: Use strerror() to print error info when possible","fromName":"Luiz Fernando N. Capitulino","fromEmail":"lcapitulino@mandriva.com.br","sentAt":"2007-04-15T23:57:09Z","receivedAt":"2007-04-15T23:57:09Z","isPatch":true,"sender":{"key":"lcapitulino@mandriva.com.br","avatar":null},"body":"Em Mon, 16 Apr 2007 01:00:20 +0200\nAlex Riesen <raa.lkml@gmail.com> escreveu:\n\n| Luiz Fernando N. Capitulino, Sun, Apr 15, 2007 23:56:19 +0200:\n| > \n| > Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>\n| > ---\n| >  entry.c |   11 ++++++-----\n| >  1 files changed, 6 insertions(+), 5 deletions(-)\n| > \n| > diff --git a/entry.c b/entry.c\n| > index d72f811..c36c09d 100644\n| > --- a/entry.c\n| > +++ b/entry.c\n| > @@ -19,7 +19,8 @@ static void create_directories(const char *path, struct checkout *state)\n| >  \t\t\t\tif (!stat(buf, &st) && S_ISDIR(st.st_mode))\n| >  \t\t\t\t\tcontinue; /* ok */\n| >  \t\t\t}\n| > -\t\t\tdie(\"cannot create directory at %s\", buf);\n| > +\t\t\tdie(\"cannot create directory at %s (%s)\", buf,\n| > +\t\t\t    strerror(errno));\n| \n| This errno is not very useful, as it may come from the stat above, and\n| you provided no way to figure out what was the syscall (the mkdir or\n| the stat) which failed. Also, the errnos of unlink or mkdir just above\n| the stat are just lost.\n| \n| It is not worse than before, but not very much better either, and\n| probably confusing. I suggest you just leave this one as it is.\n\n Will do, thanks for reviewing Alex.\n"}]}