{"thread":{"id":"66836","subject":"uname check fails on Solaris due to different return value","startedAt":"2026-11-12T15:52:49Z","lastAt":"2026-11-18T17:11:14Z","messageCount":4,"participants":["Jakub Kulik","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"558300","messageId":"SJ0PR10MB578540903B4931FFD985580C8A702@SJ0PR10MB5785.namprd10.prod.outlook.com","threadId":"66836","inReplyTo":null,"subject":"uname check fails on Solaris due to different return value","fromName":"Jakub Kulik","fromEmail":"jakub.kulik@oracle.com","sentAt":"2026-11-12T15:52:49Z","receivedAt":"2026-11-12T15:52:49Z","isPatch":false,"sender":{"key":"jakub.kulik@oracle.com","avatar":null},"body":"Hi, I encountered one more minor Solaris failure.\n\nOn 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.\n\nI managed to fix this with:\n\n--- git-2.56.0/version.c\n+++ git-2.56.0/version.c\n@@ -83,7 +83,7 @@ int get_uname_info(struct strbuf *buf, u\n {\n \tstruct utsname uname_info;\n \n-\tif (uname(&uname_info)) {\n+\tif (uname(&uname_info) < 0) {\n \t\tstrbuf_addf(buf, _(\"uname() failed with error '%s' (%d)\\n\"),\n \t\t\t    strerror(errno),\n \t\t\t    errno);\n\n\nwhich *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.\n\nThanks and Best regards,\nJakub\n\n[1] https://docs.oracle.com/cd/E88353_01/html/E37841/uname-2.html\n    https://smartos.org/man/2/uname\n[2] https://pubs.opengroup.org/onlinepubs/009604599/functions/uname.html\n\n"},{"id":"558331","messageId":"xmqqcxs9j1bp.fsf@gitster.g","threadId":"66836","inReplyTo":"SJ0PR10MB578540903B4931FFD985580C8A702@SJ0PR10MB5785.namprd10.prod.outlook.com","subject":"Re: uname check fails on Solaris due to different return value","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-12T19:29:14Z","receivedAt":"2026-11-12T19:29:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Kulik <jakub.kulik@oracle.com> writes:\n\n> Hi, I encountered one more minor Solaris failure.\n>\n> On Solaris, uname syscall returns non-negative value on success\n> and -1 on failure [1], which is different from seemingly all other\n> supported platforms, which return 0 on success (and still -1 on\n> failure). As such, the current check in version.c doesn't work on\n> Solaris.\n\nIt seems that POSIX.1 is pretty clear on this.\n\n    Upon successful completion, a non-negative value shall be\n    returned. Otherwise, -1 shall be returned and errno set to\n    indicate the error.\n\nErroring upon seeing a non-zero value like the preimage of your\npatch below *is* buggy, and the updated code looks right.\n\n> I managed to fix this with:\n>\n> --- git-2.56.0/version.c\n> +++ git-2.56.0/version.c\n> @@ -83,7 +83,7 @@ int get_uname_info(struct strbuf *buf, u\n>  {\n>  \tstruct utsname uname_info;\n>  \n> -\tif (uname(&uname_info)) {\n> +\tif (uname(&uname_info) < 0) {\n>  \t\tstrbuf_addf(buf, _(\"uname() failed with error '%s' (%d)\\n\"),\n>  \t\t\t    strerror(errno),\n>  \t\t\t    errno);\n>\n>\n> which *I think* should work on other platforms as well ([2]), but\n> I might be missing some where this change wouldn't work. Still, I\n> wanted to at least report this.\n\nThanks.  Care to make it into a real patch?\n\n"},{"id":"558719","messageId":"20261118160146.60429-2-jakub.kulik@oracle.com","threadId":"66836","inReplyTo":"xmqqcxs9j1bp.fsf@gitster.g","subject":"[PATCH] version: accept positive uname(2) return values","fromName":"Jakub Kulik","fromEmail":"jakub.kulik@oracle.com","sentAt":"2026-11-18T16:01:47Z","receivedAt":"2026-11-18T16:01:47Z","isPatch":true,"sender":{"key":"jakub.kulik@oracle.com","avatar":null},"body":"POSIX specifies that uname(2) can return any non-negative value on\nsuccess. Update the get_uname_info() check to follow this.\n\nSigned-off-by: Jakub Kulik <jakub.kulik@oracle.com>\n---\nThank you. Hope this is how it should look.\n\n version.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/version.c b/version.c\nindex 21ec7c0fbe..ca3be6d610 100644\n--- a/version.c\n+++ b/version.c\n@@ -83,7 +83,7 @@ int get_uname_info(struct strbuf *buf, unsigned int full)\n {\n \tstruct utsname uname_info;\n \n-\tif (uname(&uname_info)) {\n+\tif (uname(&uname_info) < 0) {\n \t\tstrbuf_addf(buf, _(\"uname() failed with error '%s' (%d)\\n\"),\n \t\t\t    strerror(errno),\n \t\t\t    errno);\n-- \n2.50.1\n\n\n"},{"id":"558728","messageId":"xmqqjyma6p59.fsf@gitster.g","threadId":"66836","inReplyTo":"20261118160146.60429-2-jakub.kulik@oracle.com","subject":"Re: [PATCH] version: accept positive uname(2) return values","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-18T17:11:14Z","receivedAt":"2026-11-18T17:11:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Kulik <jakub.kulik@oracle.com> writes:\n\n> POSIX specifies that uname(2) can return any non-negative value on\n> success. Update the get_uname_info() check to follow this.\n>\n> Signed-off-by: Jakub Kulik <jakub.kulik@oracle.com>\n> ---\n> Thank you. Hope this is how it should look.\n\nPerfect.  Thanks.\n\n>\n>  version.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/version.c b/version.c\n> index 21ec7c0fbe..ca3be6d610 100644\n> --- a/version.c\n> +++ b/version.c\n> @@ -83,7 +83,7 @@ int get_uname_info(struct strbuf *buf, unsigned int full)\n>  {\n>  \tstruct utsname uname_info;\n>  \n> -\tif (uname(&uname_info)) {\n> +\tif (uname(&uname_info) < 0) {\n>  \t\tstrbuf_addf(buf, _(\"uname() failed with error '%s' (%d)\\n\"),\n>  \t\t\t    strerror(errno),\n>  \t\t\t    errno);\n\n"}]}