Module Name:    src
Committed By:   jakllsch
Date:           Sat Apr 13 18:32:01 UTC 2013

Modified Files:
        src/sbin/gpt: add.c gpt.c migrate.c show.c

Log Message:
Make pre-initialized partition type uuid_t symbols 'static const'.

This conserves a few hundred bytes of total program size by
allowing the linker to merge duplicates.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/add.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/gpt/migrate.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.12 src/sbin/gpt/add.c:1.13
--- src/sbin/gpt/add.c:1.12	Sat Apr 13 18:04:33 2013
+++ src/sbin/gpt/add.c	Sat Apr 13 18:32:01 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.12 2013/04/13 18:04:33 jakllsch Exp $");
+__RCSID("$NetBSD: add.c,v 1.13 2013/04/13 18:32:01 jakllsch Exp $");
 #endif
 
 #include <sys/types.h>
@@ -218,7 +218,7 @@ cmd_add(int argc, char *argv[])
 
 	/* Create NetBSD FFS partitions by default. */
 	if (uuid_is_nil(&type, NULL)) {
-		uuid_t nb_ffs = GPT_ENT_TYPE_NETBSD_FFS;
+		static const uuid_t nb_ffs = GPT_ENT_TYPE_NETBSD_FFS;
 		type = nb_ffs;
 	}
 

Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.19 src/sbin/gpt/gpt.c:1.20
--- src/sbin/gpt/gpt.c:1.19	Sat Apr 13 18:04:33 2013
+++ src/sbin/gpt/gpt.c	Sat Apr 13 18:32:01 2013
@@ -31,7 +31,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.19 2013/04/13 18:04:33 jakllsch Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.20 2013/04/13 18:32:01 jakllsch Exp $");
 #endif
 
 #include <sys/param.h>
@@ -287,78 +287,78 @@ parse_uuid(const char *s, uuid_t *uuid)
 	switch (*s) {
 	case 'b':
 		if (strcmp(s, "bios") == 0) {
-			uuid_t bios = GPT_ENT_TYPE_BIOS;
+			static const uuid_t bios = GPT_ENT_TYPE_BIOS;
 			*uuid = bios;
 			return (0);
 		}
 		break;
 	case 'c':
 		if (strcmp(s, "ccd") == 0) {
-			uuid_t ccd = GPT_ENT_TYPE_NETBSD_CCD;
+			static const uuid_t ccd = GPT_ENT_TYPE_NETBSD_CCD;
 			*uuid = ccd;
 			return (0);
 		} else if (strcmp(s, "cgd") == 0) {
-			uuid_t cgd = GPT_ENT_TYPE_NETBSD_CGD;
+			static const uuid_t cgd = GPT_ENT_TYPE_NETBSD_CGD;
 			*uuid = cgd;
 			return (0);
 		}
 		break;
 	case 'e':
 		if (strcmp(s, "efi") == 0) {
-			uuid_t efi = GPT_ENT_TYPE_EFI;
+			static const uuid_t efi = GPT_ENT_TYPE_EFI;
 			*uuid = efi;
 			return (0);
 		}
 		break;
 	case 'f':
 		if (strcmp(s, "ffs") == 0) {
-			uuid_t nb_ffs = GPT_ENT_TYPE_NETBSD_FFS;
+			static const uuid_t nb_ffs = GPT_ENT_TYPE_NETBSD_FFS;
 			*uuid = nb_ffs;
 			return (0);
 		}
 		break;
 	case 'h':
 		if (strcmp(s, "hfs") == 0) {
-			uuid_t hfs = GPT_ENT_TYPE_APPLE_HFS;
+			static const uuid_t hfs = GPT_ENT_TYPE_APPLE_HFS;
 			*uuid = hfs;
 			return (0);
 		}
 		break;
 	case 'l':
 		if (strcmp(s, "lfs") == 0) {
-			uuid_t lfs = GPT_ENT_TYPE_NETBSD_LFS;
+			static const uuid_t lfs = GPT_ENT_TYPE_NETBSD_LFS;
 			*uuid = lfs;
 			return (0);
 		} else if (strcmp(s, "linux") == 0) {
-			uuid_t lnx = GPT_ENT_TYPE_LINUX_DATA;
+			static const uuid_t lnx = GPT_ENT_TYPE_LINUX_DATA;
 			*uuid = lnx;
 			return (0);
 		}
 		break;
 	case 'r':
 		if (strcmp(s, "raid") == 0) {
-			uuid_t raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
+			static const uuid_t raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
 			*uuid = raid;
 			return (0);
 		}
 		break;
 	case 's':
 		if (strcmp(s, "swap") == 0) {
-			uuid_t sw = GPT_ENT_TYPE_NETBSD_SWAP;
+			static const uuid_t sw = GPT_ENT_TYPE_NETBSD_SWAP;
 			*uuid = sw;
 			return (0);
 		}
 		break;
 	case 'u':
 		if (strcmp(s, "ufs") == 0) {
-			uuid_t ufs = GPT_ENT_TYPE_NETBSD_FFS;
+			static const uuid_t ufs = GPT_ENT_TYPE_NETBSD_FFS;
 			*uuid = ufs;
 			return (0);
 		}
 		break;
 	case 'w':
 		if (strcmp(s, "windows") == 0) {
-			uuid_t win = GPT_ENT_TYPE_MS_BASIC_DATA;
+			static const uuid_t win = GPT_ENT_TYPE_MS_BASIC_DATA;
 			*uuid = win;
 			return (0);
 		}

Index: src/sbin/gpt/migrate.c
diff -u src/sbin/gpt/migrate.c:1.6 src/sbin/gpt/migrate.c:1.7
--- src/sbin/gpt/migrate.c:1.6	Sat Apr 13 18:04:33 2013
+++ src/sbin/gpt/migrate.c	Sat Apr 13 18:32:01 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: migrate.c,v 1.6 2013/04/13 18:04:33 jakllsch Exp $");
+__RCSID("$NetBSD: migrate.c,v 1.7 2013/04/13 18:32:01 jakllsch Exp $");
 #endif
 
 #include <sys/types.h>
@@ -106,21 +106,21 @@ migrate_disklabel(int fd, off_t start, s
 		case FS_UNUSED:
 			continue;
 		case FS_SWAP: {
-			uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
+			static const uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
 			le_uuid_enc(ent->ent_type, &swap);
 			utf8_to_utf16((const uint8_t *)"FreeBSD swap partition",
 			    ent->ent_name, 36);
 			break;
 		}
 		case FS_BSDFFS: {
-			uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+			static const uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
 			le_uuid_enc(ent->ent_type, &ufs);
 			utf8_to_utf16((const uint8_t *)"FreeBSD UFS partition",
 			    ent->ent_name, 36);
 			break;
 		}
 		case FS_VINUM: {
-			uuid_t vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
+			static const uuid_t vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
 			le_uuid_enc(ent->ent_type, &vinum);
 			utf8_to_utf16((const uint8_t *)"FreeBSD vinum partition",
 			    ent->ent_name, 36);
@@ -259,7 +259,7 @@ migrate(int fd)
 			continue;
 		case 165: {	/* FreeBSD */
 			if (slice) {
-				uuid_t freebsd = GPT_ENT_TYPE_FREEBSD;
+				static const uuid_t freebsd = GPT_ENT_TYPE_FREEBSD;
 				le_uuid_enc(ent->ent_type, &freebsd);
 				ent->ent_lba_start = htole64((uint64_t)start);
 				ent->ent_lba_end = htole64(start + size - 1LL);
@@ -271,7 +271,7 @@ migrate(int fd)
 			break;
 		}
 		case 239: {	/* EFI */
-			uuid_t efi_slice = GPT_ENT_TYPE_EFI;
+			static const uuid_t efi_slice = GPT_ENT_TYPE_EFI;
 			le_uuid_enc(ent->ent_type, &efi_slice);
 			ent->ent_lba_start = htole64((uint64_t)start);
 			ent->ent_lba_end = htole64(start + size - 1LL);

Index: src/sbin/gpt/show.c
diff -u src/sbin/gpt/show.c:1.9 src/sbin/gpt/show.c:1.10
--- src/sbin/gpt/show.c:1.9	Sat Apr 13 18:04:33 2013
+++ src/sbin/gpt/show.c	Sat Apr 13 18:32:01 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: show.c,v 1.9 2013/04/13 18:04:33 jakllsch Exp $");
+__RCSID("$NetBSD: show.c,v 1.10 2013/04/13 18:32:01 jakllsch Exp $");
 #endif
 
 #include <sys/types.h>
@@ -61,23 +61,23 @@ usage_show(void)
 static const char *
 friendly(uuid_t *t)
 {
-	static uuid_t efi_slice = GPT_ENT_TYPE_EFI;
-	static uuid_t bios_boot = GPT_ENT_TYPE_BIOS;
-	static uuid_t msdata = GPT_ENT_TYPE_MS_BASIC_DATA;
-	static uuid_t freebsd = GPT_ENT_TYPE_FREEBSD;
-	static uuid_t hfs = GPT_ENT_TYPE_APPLE_HFS;
-	static uuid_t linuxdata = GPT_ENT_TYPE_LINUX_DATA;
-	static uuid_t linuxswap = GPT_ENT_TYPE_LINUX_SWAP;
-	static uuid_t msr = GPT_ENT_TYPE_MS_RESERVED;
-	static uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
-	static uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
-	static uuid_t vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
-	static uuid_t nb_swap = GPT_ENT_TYPE_NETBSD_SWAP;
-	static uuid_t nb_ffs = GPT_ENT_TYPE_NETBSD_FFS;
-	static uuid_t nb_lfs = GPT_ENT_TYPE_NETBSD_LFS;
-	static uuid_t nb_raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
-	static uuid_t nb_ccd = GPT_ENT_TYPE_NETBSD_CCD;
-	static uuid_t nb_cgd = GPT_ENT_TYPE_NETBSD_CGD;
+	static const uuid_t efi_slice = GPT_ENT_TYPE_EFI;
+	static const uuid_t bios_boot = GPT_ENT_TYPE_BIOS;
+	static const uuid_t msdata = GPT_ENT_TYPE_MS_BASIC_DATA;
+	static const uuid_t freebsd = GPT_ENT_TYPE_FREEBSD;
+	static const uuid_t hfs = GPT_ENT_TYPE_APPLE_HFS;
+	static const uuid_t linuxdata = GPT_ENT_TYPE_LINUX_DATA;
+	static const uuid_t linuxswap = GPT_ENT_TYPE_LINUX_SWAP;
+	static const uuid_t msr = GPT_ENT_TYPE_MS_RESERVED;
+	static const uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
+	static const uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+	static const uuid_t vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
+	static const uuid_t nb_swap = GPT_ENT_TYPE_NETBSD_SWAP;
+	static const uuid_t nb_ffs = GPT_ENT_TYPE_NETBSD_FFS;
+	static const uuid_t nb_lfs = GPT_ENT_TYPE_NETBSD_LFS;
+	static const uuid_t nb_raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
+	static const uuid_t nb_ccd = GPT_ENT_TYPE_NETBSD_CCD;
+	static const uuid_t nb_cgd = GPT_ENT_TYPE_NETBSD_CGD;
 	static char buf[80];
 	char *s;
 

Reply via email to