Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Cosmetics: consistently use MEG and GIG def...



details:   https://anonhg.NetBSD.org/src/rev/00e8d4614cab
branches:  trunk
changeset: 837289:00e8d4614cab
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Nov 27 17:13:41 2018 +0000

description:
Cosmetics: consistently use MEG and GIG defines for size calculations

diffstat:

 usr.sbin/sysinst/arch/i386/md.c |   5 +++--
 usr.sbin/sysinst/defs.h         |   5 +++--
 usr.sbin/sysinst/disks.c        |   4 ++--
 usr.sbin/sysinst/label.c        |  10 +++++-----
 usr.sbin/sysinst/mbr.c          |  10 +++++-----
 usr.sbin/sysinst/partman.c      |   8 ++++----
 6 files changed, 22 insertions(+), 20 deletions(-)

diffs (165 lines):

diff -r 9b27e6e91992 -r 00e8d4614cab usr.sbin/sysinst/arch/i386/md.c
--- a/usr.sbin/sysinst/arch/i386/md.c   Tue Nov 27 14:55:56 2018 +0000
+++ b/usr.sbin/sysinst/arch/i386/md.c   Tue Nov 27 17:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.13 2018/09/15 18:04:21 martin Exp $ */
+/*     $NetBSD: md.c,v 1.14 2018/11/27 17:13:41 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -540,7 +540,8 @@
 static int
 mbr_root_above_chs(void)
 {
-       return pm->ptstart + DEFROOTSIZE * (MEG / 512) >= bcyl * bhead * bsec;
+       return pm->ptstart + DEFROOTSIZE * (MEG / 512)
+           >= (unsigned long)bcyl * bhead * bsec;
 }
 
 static void
diff -r 9b27e6e91992 -r 00e8d4614cab usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Tue Nov 27 14:55:56 2018 +0000
+++ b/usr.sbin/sysinst/defs.h   Tue Nov 27 17:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.27 2018/11/19 17:17:43 martin Exp $ */
+/*     $NetBSD: defs.h,v 1.28 2018/11/27 17:13:41 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -52,7 +52,8 @@
 #define max(a,b)       ((a) > (b) ? (a) : (b))
 
 /* constants */
-#define MEG (1024 * 1024)
+#define MEG (1024 * 1024UL)
+#define GIG (1024 * MEG)
 #define STRSIZE 255
 #define SSTRSIZE 30
 
diff -r 9b27e6e91992 -r 00e8d4614cab usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Tue Nov 27 14:55:56 2018 +0000
+++ b/usr.sbin/sysinst/disks.c  Tue Nov 27 17:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.27 2018/11/14 02:30:00 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.28 2018/11/27 17:13:41 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -137,7 +137,7 @@
        if (sysctlbyname("hw.usermem64", &ram, &len, NULL, 0))
                return false;
 
-       return ram > 16UL*1024UL*1024UL;
+       return ram > 16 * MEG;
 }
 
 /* from src/sbin/atactl/atactl.c
diff -r 9b27e6e91992 -r 00e8d4614cab usr.sbin/sysinst/label.c
--- a/usr.sbin/sysinst/label.c  Tue Nov 27 14:55:56 2018 +0000
+++ b/usr.sbin/sysinst/label.c  Tue Nov 27 17:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: label.c,v 1.4 2018/11/20 19:02:07 martin Exp $ */
+/*     $NetBSD: label.c,v 1.5 2018/11/27 17:13:41 martin Exp $ */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.4 2018/11/20 19:02:07 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.5 2018/11/27 17:13:41 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -233,11 +233,11 @@
                 * >= 128 GB    4 KB
                 */
                /* note pi_size is uint32_t so we have to avoid overflow */
-               if (p->pi_size < (20 * 1024 * (1024 / 512)))
+               if (p->pi_size < (20 * MEG / 512))
                        p->pi_fsize = 512;
-               else if (p->pi_size < (1000 * 1024 * (1024 / 512)))
+               else if (p->pi_size < (1000 * MEG / 512))
                        p->pi_fsize = 1024;
-               else if (p->pi_size < (128 * 1024 * 1024 * (1024 / 512)))
+               else if (p->pi_size < (128 * GIG / 512))
                        p->pi_fsize = 2048;
                else
                        p->pi_fsize = 4096;
diff -r 9b27e6e91992 -r 00e8d4614cab usr.sbin/sysinst/mbr.c
--- a/usr.sbin/sysinst/mbr.c    Tue Nov 27 14:55:56 2018 +0000
+++ b/usr.sbin/sysinst/mbr.c    Tue Nov 27 17:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbr.c,v 1.9 2018/11/20 19:02:07 martin Exp $ */
+/*     $NetBSD: mbr.c,v 1.10 2018/11/27 17:13:41 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1284,10 +1284,10 @@
                char min_size[5], build_size[5];
 
                humanize_number(min_size, sizeof(min_size),
-                   2 * m_size * 1024*1024UL,
+                   2 * m_size * MEG,
                    "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
                humanize_number(build_size, sizeof(build_size),
-                    SYSTEM_BUILD_SIZE * 1024 * 1024UL, "", HN_AUTOSCALE,
+                    SYSTEM_BUILD_SIZE * MEG, "", HN_AUTOSCALE,
                     HN_B | HN_NOSPACE | HN_DECIMAL);
 
                msg_display_subst(MSG_fullpart, 7,
@@ -1485,7 +1485,7 @@
 
        ptn_0_offset = bsec;
        /* use 1MB default offset on large disks as fdisk(8) */
-       if (pm->dlsize > 2048 * 1024 * 128)
+       if ((unsigned long)pm->dlsize > 128 * GIG / 512)
                ptn_0_offset = 2048;
 
        memset(mbri, 0, sizeof *mbri);
@@ -1917,7 +1917,7 @@
                }
        } else {
                /* Use 1MB offset for large (>128GB) disks */
-               if (pm->dlsize > 2048 * 1024 * 128) {
+               if ((unsigned long)pm->dlsize > 128 * GIG / 512) {
                        ptn_alignment = 2048;
                        ptn_0_offset = 2048;
                }
diff -r 9b27e6e91992 -r 00e8d4614cab usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c        Tue Nov 27 14:55:56 2018 +0000
+++ b/usr.sbin/sysinst/partman.c        Tue Nov 27 17:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partman.c,v 1.23 2018/11/20 19:02:07 martin Exp $ */
+/*     $NetBSD: partman.c,v 1.24 2018/11/27 17:13:41 martin Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -2504,7 +2504,7 @@
                        snprintf(buf, STRSIZE, "dk%d: %s",
                                part_num,
                                wedges[part_num].pm->bsdlabel[wedges[part_num].ptn].pi_mount);
-                       wprintw(m->mw, "   %-30.29s %-22.21s %11uM",
+                       wprintw(m->mw, "   %-30.29s %-22.21s %11luM",
                                buf,
                                (wedges[part_num].pm->bsdlabel[wedges[part_num].ptn].lvmpv) ? 
                                        "lvm pv" :
@@ -2523,7 +2523,7 @@
                                                strlen (pm_cur->bsdlabel[part_num].pi_mount ) < 1 ||
                                                pm_cur->bsdlabel[part_num].pi_flags & PIF_MOUNT) ?
                                                "" : msg_string(MSG_pmunused));
-                       wprintw(m->mw, "   %-30.29s %-22.21s %11uM",
+                       wprintw(m->mw, "   %-30.29s %-22.21s %11luM",
                                buf,
                                (pm_cur->bsdlabel[part_num].lvmpv) ? 
                                        "lvm pv" :
@@ -2533,7 +2533,7 @@
                case PM_SPEC_T:
                        snprintf(buf, STRSIZE, "%s: %s",
                                pm_cur->diskdev_descr, pm_cur->bsdlabel[0].pi_mount);
-                       wprintw(m->mw, "%-33.32s %-22.21s %11uM", buf,
+                       wprintw(m->mw, "%-33.32s %-22.21s %11luM", buf,
                                getfslabelname(pm_cur->bsdlabel[0].pi_fstype),
                                pm_cur->bsdlabel[0].pi_size / (MEG / pm_cur->sectorsize));
                        break;



Home | Main Index | Thread Index | Old Index