diff mbox series

[07/13] spaces and errors fix Handled git pipeline errors

Message ID 8165196f869267ff35d2b252c20a622013b0fb04.1699871056.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Enabling z/OS workflow for git | expand

Commit Message

Haritha D Nov. 13, 2023, 10:24 a.m. UTC
From: Haritha D <harithamma.d@ibm.com>

This PR has fixes to enable build on z/OS

Signed-off-by: Harithamma D <harithamma.d@ibm.com>
---
 convert.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/convert.c b/convert.c
index 7fe107710ec..c8d30011458 100644
--- a/convert.c
+++ b/convert.c
@@ -1314,9 +1314,15 @@  static int git_path_check_ident(struct attr_check_item *check)
 static struct attr_check *check;
 
 static const char* get_platform(void) {
-	struct utsname uname_info = {0};
+	struct utsname uname_info;
 	char *result = NULL;
-	if(!uname_info.sysname[0])
+
+	if (uname(&uname_info) < 0)
+		die(_("uname() failed with error '%s' (%d)\n"),
+			strerror(errno),
+			errno);
+
+	if(*uname_info.sysname != '\0')
 	{
 		int index=0;
 		result = (char *)malloc(strlen(uname_info.sysname)+1);
@@ -1326,15 +1332,13 @@  static const char* get_platform(void) {
 			++result;
 			++index;
 		}
+		*result = '\0';
 	}
 
-	if (uname(&uname_info))
-		die(_("uname() failed with error '%s' (%d)\n"),
-			    strerror(errno),
-			    errno);
-
+#ifdef __MVS__
 	if (!strcmp(uname_info.sysname, "OS/390"))
 		result="zos";
+#endif
 
 	return result;
 }