All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jakub Kulik <jakub.kulik@oracle.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: uname check fails on Solaris due to different return value
Date: Thu, 12 Nov 2026 11:29:14 -0800	[thread overview]
Message-ID: <xmqqcxs9j1bp.fsf@gitster.g> (raw)
In-Reply-To: <SJ0PR10MB578540903B4931FFD985580C8A702@SJ0PR10MB5785.namprd10.prod.outlook.com> (Jakub Kulik's message of "Thu, 12 Nov 2026 15:52:49 +0000")

Jakub Kulik <jakub.kulik@oracle.com> writes:

> Hi, I encountered one more minor Solaris failure.
>
> On Solaris, uname syscall returns non-negative value on success
> and -1 on failure [1], which is different from seemingly all other
> supported platforms, which return 0 on success (and still -1 on
> failure). As such, the current check in version.c doesn't work on
> Solaris.

It seems that POSIX.1 is pretty clear on this.

    Upon successful completion, a non-negative value shall be
    returned. Otherwise, -1 shall be returned and errno set to
    indicate the error.

Erroring upon seeing a non-zero value like the preimage of your
patch below *is* buggy, and the updated code looks right.

> I managed to fix this with:
>
> --- git-2.56.0/version.c
> +++ git-2.56.0/version.c
> @@ -83,7 +83,7 @@ int get_uname_info(struct strbuf *buf, u
>  {
>  	struct utsname uname_info;
>  
> -	if (uname(&uname_info)) {
> +	if (uname(&uname_info) < 0) {
>  		strbuf_addf(buf, _("uname() failed with error '%s' (%d)\n"),
>  			    strerror(errno),
>  			    errno);
>
>
> which *I think* should work on other platforms as well ([2]), but
> I might be missing some where this change wouldn't work. Still, I
> wanted to at least report this.

Thanks.  Care to make it into a real patch?

      reply	other threads:[~2026-11-12 19:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 15:52 uname check fails on Solaris due to different return value Jakub Kulik
2026-11-12 19:29 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqcxs9j1bp.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jakub.kulik@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.