* [PATCH] Fix detection of uname failure
@ 2015-07-17 12:11 Charles Bailey
2015-07-17 13:06 ` Johannes Schindelin
0 siblings, 1 reply; 8+ messages in thread
From: Charles Bailey @ 2015-07-17 12:11 UTC (permalink / raw)
To: Junio C Hamano, git
From: Charles Bailey <cbailey32@bloomberg.net>
According to POSIX specification uname must return -1 on failure and a
non-negative value on success. Although many implementations do return 0
on success it is valid to return any positive value for success. In
particular, Solaris returns 1.
Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
---
dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dir.c b/dir.c
index 8209f8b..52dbfd0 100644
--- a/dir.c
+++ b/dir.c
@@ -1848,7 +1848,7 @@ static const char *get_ident_string(void)
if (sb.len)
return sb.buf;
- if (uname(&uts))
+ if (uname(&uts) == -1)
die_errno(_("failed to get kernel name and information"));
strbuf_addf(&sb, "Location %s, system %s %s %s", get_git_work_tree(),
uts.sysname, uts.release, uts.version);
--
2.4.0.53.g8440f74
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix detection of uname failure
2015-07-17 12:11 [PATCH] Fix detection of uname failure Charles Bailey
@ 2015-07-17 13:06 ` Johannes Schindelin
2015-07-17 17:01 ` Charles Bailey
2015-07-17 17:09 ` [PATCH v2] " Charles Bailey
0 siblings, 2 replies; 8+ messages in thread
From: Johannes Schindelin @ 2015-07-17 13:06 UTC (permalink / raw)
To: Charles Bailey; +Cc: Junio C Hamano, git
Hi Charles,
On 2015-07-17 14:11, Charles Bailey wrote:
> diff --git a/dir.c b/dir.c
> index 8209f8b..52dbfd0 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -1848,7 +1848,7 @@ static const char *get_ident_string(void)
>
> if (sb.len)
> return sb.buf;
> - if (uname(&uts))
> + if (uname(&uts) == -1)
>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?
Ciao,
Johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix detection of uname failure
2015-07-17 13:06 ` Johannes Schindelin
@ 2015-07-17 17:01 ` Charles Bailey
2015-07-17 17:09 ` Junio C Hamano
2015-07-17 17:09 ` [PATCH v2] " Charles Bailey
1 sibling, 1 reply; 8+ messages in thread
From: Charles Bailey @ 2015-07-17 17:01 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git
On Fri, Jul 17, 2015 at 03:06:57PM +0200, Johannes Schindelin wrote:
>
> 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?
I did the same grep and found lots of examples of both. Many of the "<
0" applied to comparisons with variables and not API calls and many were
internal (to git) calls and not POSIX or C library calls so I wasn't
convinced to change my initial fix.
Having said that and thought about it some more, I think '< 0' is
probably better. In POSIX, we shouldn't ever get a negative value which
isn't -1, but if we ever do it is probably safer to fail. I'll send and
update.
Charles.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix detection of uname failure
2015-07-17 17:01 ` Charles Bailey
@ 2015-07-17 17:09 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2015-07-17 17:09 UTC (permalink / raw)
To: Charles Bailey; +Cc: Johannes Schindelin, git
Charles Bailey <charles@hashpling.org> writes:
> ... I think '< 0' is
> probably better. In POSIX, we shouldn't ever get a negative value which
> isn't -1, but if we ever do it is probably safer to fail. I'll send and
> update.
Thanks; I was about to type the same reasoning and conclusion ;-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] Fix detection of uname failure
2015-07-17 13:06 ` Johannes Schindelin
2015-07-17 17:01 ` Charles Bailey
@ 2015-07-17 17:09 ` Charles Bailey
2015-07-17 21:07 ` Johannes Schindelin
1 sibling, 1 reply; 8+ messages in thread
From: Charles Bailey @ 2015-07-17 17:09 UTC (permalink / raw)
To: Junio C Hamano, git, Johannes Schindelin
From: Charles Bailey <cbailey32@bloomberg.net>
According to POSIX specification uname must return -1 on failure and a
non-negative value on success. Although many implementations do return 0
on success it is valid to return any positive value for success. In
particular, Solaris returns 1.
Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
---
dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dir.c b/dir.c
index 8209f8b..1d42811 100644
--- a/dir.c
+++ b/dir.c
@@ -1848,7 +1848,7 @@ static const char *get_ident_string(void)
if (sb.len)
return sb.buf;
- if (uname(&uts))
+ if (uname(&uts) < 0)
die_errno(_("failed to get kernel name and information"));
strbuf_addf(&sb, "Location %s, system %s %s %s", get_git_work_tree(),
uts.sysname, uts.release, uts.version);
--
2.4.0.53.g8440f74
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Fix detection of uname failure
2015-07-17 17:09 ` [PATCH v2] " Charles Bailey
@ 2015-07-17 21:07 ` Johannes Schindelin
2015-07-17 21:39 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2015-07-17 21:07 UTC (permalink / raw)
To: Charles Bailey; +Cc: Junio C Hamano, git
On 2015-07-17 19:09, Charles Bailey wrote:
> From: Charles Bailey <cbailey32@bloomberg.net>
>
> According to POSIX specification uname must return -1 on failure and a
> non-negative value on success. Although many implementations do return 0
> on success it is valid to return any positive value for success. In
> particular, Solaris returns 1.
>
> Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Fix detection of uname failure
2015-07-17 21:07 ` Johannes Schindelin
@ 2015-07-17 21:39 ` Junio C Hamano
2015-07-18 6:58 ` Johannes Schindelin
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2015-07-17 21:39 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Charles Bailey, git
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> On 2015-07-17 19:09, Charles Bailey wrote:
>> From: Charles Bailey <cbailey32@bloomberg.net>
>>
>> According to POSIX specification uname must return -1 on failure and a
>> non-negative value on success. Although many implementations do return 0
>> on success it is valid to return any positive value for success. In
>> particular, Solaris returns 1.
>>
>> Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
>
> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
I'd s/Ack/Review/; as the original is not your code but you are well
qualified (and have my trust) to judge the change to this codepath
;-)
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Fix detection of uname failure
2015-07-17 21:39 ` Junio C Hamano
@ 2015-07-18 6:58 ` Johannes Schindelin
0 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2015-07-18 6:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Charles Bailey, git
Hi Junio,
On 2015-07-17 23:39, Junio C Hamano wrote:
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>
>> On 2015-07-17 19:09, Charles Bailey wrote:
>>> From: Charles Bailey <cbailey32@bloomberg.net>
>>>
>>> According to POSIX specification uname must return -1 on failure and a
>>> non-negative value on success. Although many implementations do return 0
>>> on success it is valid to return any positive value for success. In
>>> particular, Solaris returns 1.
>>>
>>> Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
>>
>> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> I'd s/Ack/Review/; as the original is not your code but you are well
> qualified (and have my trust) to judge the change to this codepath
> ;-)
Yeah, that's what I meant ;-)
Ciao,
Dscho
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-07-18 6:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-17 12:11 [PATCH] Fix detection of uname failure Charles Bailey
2015-07-17 13:06 ` Johannes Schindelin
2015-07-17 17:01 ` Charles Bailey
2015-07-17 17:09 ` Junio C Hamano
2015-07-17 17:09 ` [PATCH v2] " Charles Bailey
2015-07-17 21:07 ` Johannes Schindelin
2015-07-17 21:39 ` Junio C Hamano
2015-07-18 6:58 ` Johannes Schindelin
Code repositories for project(s) associated with this public inbox
https://public-inbox.org/git.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).