Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Make pre-initialized partition type uuid_t symbols ...



details:   https://anonhg.NetBSD.org/src/rev/751b8786b41b
branches:  trunk
changeset: 786071:751b8786b41b
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Apr 13 18:32:01 2013 +0000

description:
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.

diffstat:

 sbin/gpt/add.c     |   4 ++--
 sbin/gpt/gpt.c     |  26 +++++++++++++-------------
 sbin/gpt/migrate.c |  12 ++++++------
 sbin/gpt/show.c    |  36 ++++++++++++++++++------------------
 4 files changed, 39 insertions(+), 39 deletions(-)

diffs (232 lines):

diff -r c4fd82cfbe2c -r 751b8786b41b sbin/gpt/add.c
--- a/sbin/gpt/add.c    Sat Apr 13 18:25:56 2013 +0000
+++ b/sbin/gpt/add.c    Sat Apr 13 18:32:01 2013 +0000
@@ -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 @@
 
        /* 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;
        }
 
diff -r c4fd82cfbe2c -r 751b8786b41b sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c    Sat Apr 13 18:25:56 2013 +0000
+++ b/sbin/gpt/gpt.c    Sat Apr 13 18:32:01 2013 +0000
@@ -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 @@
        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);
                }
diff -r c4fd82cfbe2c -r 751b8786b41b sbin/gpt/migrate.c
--- a/sbin/gpt/migrate.c        Sat Apr 13 18:25:56 2013 +0000
+++ b/sbin/gpt/migrate.c        Sat Apr 13 18:32:01 2013 +0000
@@ -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 @@
                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 @@
                        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 @@
                        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);
diff -r c4fd82cfbe2c -r 751b8786b41b sbin/gpt/show.c
--- a/sbin/gpt/show.c   Sat Apr 13 18:25:56 2013 +0000
+++ b/sbin/gpt/show.c   Sat Apr 13 18:32:01 2013 +0000
@@ -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 @@
 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;
 



Home | Main Index | Thread Index | Old Index