{"thread":{"id":"39870","subject":"[PATCH] Fix detection of uname failure","startedAt":"2015-07-17T12:11:35Z","lastAt":"2015-07-18T06:58:50Z","messageCount":8,"participants":["Charles Bailey","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"266231","messageId":"1437135095-6244-1-git-send-email-charles@hashpling.org","threadId":"39870","inReplyTo":null,"subject":"[PATCH] Fix detection of uname failure","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2015-07-17T12:11:35Z","receivedAt":"2015-07-17T12:11:35Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"From: Charles Bailey <cbailey32@bloomberg.net>\n\nAccording to POSIX specification uname must return -1 on failure and a\nnon-negative value on success. Although many implementations do return 0\non success it is valid to return any positive value for success.  In\nparticular, Solaris returns 1.\n\nSigned-off-by: Charles Bailey <cbailey32@bloomberg.net>\n---\n dir.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/dir.c b/dir.c\nindex 8209f8b..52dbfd0 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1848,7 +1848,7 @@ static const char *get_ident_string(void)\n \n \tif (sb.len)\n \t\treturn sb.buf;\n-\tif (uname(&uts))\n+\tif (uname(&uts) == -1)\n \t\tdie_errno(_(\"failed to get kernel name and information\"));\n \tstrbuf_addf(&sb, \"Location %s, system %s %s %s\", get_git_work_tree(),\n \t\t    uts.sysname, uts.release, uts.version);\n-- \n2.4.0.53.g8440f74\n"},{"id":"266235","messageId":"ef7d56584c3b5d6431f895df1d94eba8@www.dscho.org","threadId":"39870","inReplyTo":"1437135095-6244-1-git-send-email-charles@hashpling.org","subject":"Re: [PATCH] Fix detection of uname failure","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-17T13:06:57Z","receivedAt":"2015-07-17T13:06:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Charles,\n\nOn 2015-07-17 14:11, Charles Bailey wrote:\n\n> diff --git a/dir.c b/dir.c\n> index 8209f8b..52dbfd0 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -1848,7 +1848,7 @@ static const char *get_ident_string(void)\n>  \n>  \tif (sb.len)\n>  \t\treturn sb.buf;\n> -\tif (uname(&uts))\n> +\tif (uname(&uts) == -1)\n\n>From a quick `git grep '== -1'` and another quick `git grep '< 0'` it appears to me that we prefer the latter. Maybe you want to adjust it in the patch, too?\n\nCiao,\nJohannes\n"},{"id":"266247","messageId":"20150717170142.GA9616@hashpling.org","threadId":"39870","inReplyTo":"ef7d56584c3b5d6431f895df1d94eba8@www.dscho.org","subject":"Re: [PATCH] Fix detection of uname failure","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2015-07-17T17:01:42Z","receivedAt":"2015-07-17T17:01:42Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Fri, Jul 17, 2015 at 03:06:57PM +0200, Johannes Schindelin wrote:\n> \n> From a quick `git grep '== -1'` and another quick `git grep '< 0'` it appears to me that we prefer the latter. Maybe you want to adjust it in the patch, too?\n\nI did the same grep and found lots of examples of both. Many of the \"<\n0\" applied to comparisons with variables and not API calls and many were\ninternal (to git) calls and not POSIX or C library calls so I wasn't\nconvinced to change my initial fix.\n\nHaving said that and thought about it some more, I think '< 0' is\nprobably better. In POSIX, we shouldn't ever get a negative value which\nisn't -1, but if we ever do it is probably safer to fail. I'll send and\nupdate.\n\nCharles.\n"},{"id":"266251","messageId":"xmqq615i3e4m.fsf@gitster.dls.corp.google.com","threadId":"39870","inReplyTo":"20150717170142.GA9616@hashpling.org","subject":"Re: [PATCH] Fix detection of uname failure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-17T17:09:13Z","receivedAt":"2015-07-17T17:09:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Charles Bailey <charles@hashpling.org> writes:\n\n> ... I think '< 0' is\n> probably better. In POSIX, we shouldn't ever get a negative value which\n> isn't -1, but if we ever do it is probably safer to fail. I'll send and\n> update.\n\nThanks; I was about to type the same reasoning and conclusion ;-)\n"},{"id":"266252","messageId":"1437152981-28855-1-git-send-email-charles@hashpling.org","threadId":"39870","inReplyTo":"ef7d56584c3b5d6431f895df1d94eba8@www.dscho.org","subject":"[PATCH v2] Fix detection of uname failure","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2015-07-17T17:09:41Z","receivedAt":"2015-07-17T17:09:41Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"From: Charles Bailey <cbailey32@bloomberg.net>\n\nAccording to POSIX specification uname must return -1 on failure and a\nnon-negative value on success. Although many implementations do return 0\non success it is valid to return any positive value for success.  In\nparticular, Solaris returns 1.\n\nSigned-off-by: Charles Bailey <cbailey32@bloomberg.net>\n---\n dir.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/dir.c b/dir.c\nindex 8209f8b..1d42811 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1848,7 +1848,7 @@ static const char *get_ident_string(void)\n \n \tif (sb.len)\n \t\treturn sb.buf;\n-\tif (uname(&uts))\n+\tif (uname(&uts) < 0)\n \t\tdie_errno(_(\"failed to get kernel name and information\"));\n \tstrbuf_addf(&sb, \"Location %s, system %s %s %s\", get_git_work_tree(),\n \t\t    uts.sysname, uts.release, uts.version);\n-- \n2.4.0.53.g8440f74\n"},{"id":"266267","messageId":"7cf6757e8e81c2f9e102db24efbedb2a@www.dscho.org","threadId":"39870","inReplyTo":"1437152981-28855-1-git-send-email-charles@hashpling.org","subject":"Re: [PATCH v2] Fix detection of uname failure","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-17T21:07:55Z","receivedAt":"2015-07-17T21:07:55Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"On 2015-07-17 19:09, Charles Bailey wrote:\n> From: Charles Bailey <cbailey32@bloomberg.net>\n> \n> According to POSIX specification uname must return -1 on failure and a\n> non-negative value on success. Although many implementations do return 0\n> on success it is valid to return any positive value for success.  In\n> particular, Solaris returns 1.\n> \n> Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>\n\nAcked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n"},{"id":"266272","messageId":"xmqq7fpy1n0z.fsf@gitster.dls.corp.google.com","threadId":"39870","inReplyTo":"7cf6757e8e81c2f9e102db24efbedb2a@www.dscho.org","subject":"Re: [PATCH v2] Fix detection of uname failure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-17T21:39:56Z","receivedAt":"2015-07-17T21:39:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n> On 2015-07-17 19:09, Charles Bailey wrote:\n>> From: Charles Bailey <cbailey32@bloomberg.net>\n>> \n>> According to POSIX specification uname must return -1 on failure and a\n>> non-negative value on success. Although many implementations do return 0\n>> on success it is valid to return any positive value for success.  In\n>> particular, Solaris returns 1.\n>> \n>> Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>\n>\n> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nI'd s/Ack/Review/; as the original is not your code but you are well\nqualified (and have my trust) to judge the change to this codepath\n;-)\n\nThanks.\n"},{"id":"266320","messageId":"e6959e1763d2f5cb2d14618a61edfab9@www.dscho.org","threadId":"39870","inReplyTo":"xmqq7fpy1n0z.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2] Fix detection of uname failure","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-18T06:58:50Z","receivedAt":"2015-07-18T06:58:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn 2015-07-17 23:39, Junio C Hamano wrote:\n> Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n> \n>> On 2015-07-17 19:09, Charles Bailey wrote:\n>>> From: Charles Bailey <cbailey32@bloomberg.net>\n>>>\n>>> According to POSIX specification uname must return -1 on failure and a\n>>> non-negative value on success. Although many implementations do return 0\n>>> on success it is valid to return any positive value for success.  In\n>>> particular, Solaris returns 1.\n>>>\n>>> Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>\n>>\n>> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> \n> I'd s/Ack/Review/; as the original is not your code but you are well\n> qualified (and have my trust) to judge the change to this codepath\n> ;-)\n\nYeah, that's what I meant ;-)\n\nCiao,\nDscho\n"}]}