Loading...
gen/disklabel.c Libc-763.13 Libc-1669.40.2
--- Libc/Libc-763.13/gen/disklabel.c
+++ Libc/Libc-1669.40.2/gen/disklabel.c
@@ -70,18 +70,19 @@
 #include <unistd.h>
 #include <ctype.h>
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcomma"
+
 #ifdef unused
 static int	error(int);
 #endif // unused
-static int	gettype(char *, char **);
+static int	gettype(const char *, const char **);
 
 struct disklabel *
-getdiskbyname(name)
-	const char *name;
+getdiskbyname(const char *name)
 {
-	static struct	disklabel disk;
-	register struct	disklabel *dp = &disk;
-	register struct partition *pp;
+	static struct disklabel *dp = NULL;
+	struct partition *pp;
 	char	*buf;
 	char  	*db_array[2] = { _PATH_DISKTAB, 0 };
 	char	*cp, *cq;	/* can't be register */
@@ -92,7 +93,14 @@
 	if (cgetent(&buf, db_array, (char *) name) < 0)
 		return NULL;
 
-	bzero((char *)&disk, sizeof(disk));
+	if (dp == NULL) {
+		dp = malloc(sizeof(struct disklabel));
+		if (dp == NULL) {
+			return NULL;
+		}
+	}
+	memset(dp, 0, sizeof(struct disklabel));
+
 	/*
 	 * typename
 	 */
@@ -116,7 +124,7 @@
 		dp->d_flags |= D_BADSECT;
 
 #define getnumdflt(field, dname, dflt) \
-        { long f; (field) = (cgetnum(buf, dname, &f) == -1) ? (dflt) : f; }
+        { long f; (field) = (typeof(field))((cgetnum(buf, dname, &f) == -1) ? (dflt) : f); }
 
 	getnumdflt(dp->d_secsize, "se", DEV_BSIZE);
 	cgetnum(buf, "nt",(long *) &dp->d_ntracks);
@@ -179,15 +187,13 @@
 }
 
 static int
-gettype(t, names)
-	char *t;
-	char **names;
+gettype(const char *t, const char **names)
 {
-	register char **nm;
+	const char **nm;
 
 	for (nm = names; *nm; nm++)
 		if (strcasecmp(t, *nm) == 0)
-			return (nm - names);
+			return (int)(nm - names);
 	if (isdigit(*t))
 		return (atoi(t));
 	return (0);
@@ -208,3 +214,5 @@
 	(void)write(STDERR_FILENO, "\n", 1);
 }
 #endif // unused
+#pragma clang diagnostic pop
+