Module Name: src Committed By: martin Date: Tue Nov 27 17:13:41 UTC 2018
Modified Files: src/usr.sbin/sysinst: defs.h disks.c label.c mbr.c partman.c src/usr.sbin/sysinst/arch/i386: md.c Log Message: Cosmetics: consistently use MEG and GIG defines for size calculations To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sysinst/defs.h \ src/usr.sbin/sysinst/disks.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/label.c cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sysinst/mbr.c cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/sysinst/partman.c cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/arch/i386/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/sysinst/defs.h diff -u src/usr.sbin/sysinst/defs.h:1.27 src/usr.sbin/sysinst/defs.h:1.28 --- src/usr.sbin/sysinst/defs.h:1.27 Mon Nov 19 17:17:43 2018 +++ src/usr.sbin/sysinst/defs.h Tue Nov 27 17:13:41 2018 @@ -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 @@ const char *getfslabelname(uint8_t); #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 Index: src/usr.sbin/sysinst/disks.c diff -u src/usr.sbin/sysinst/disks.c:1.27 src/usr.sbin/sysinst/disks.c:1.28 --- src/usr.sbin/sysinst/disks.c:1.27 Wed Nov 14 02:30:00 2018 +++ src/usr.sbin/sysinst/disks.c Tue Nov 27 17:13:41 2018 @@ -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 @@ tmpfs_on_var_shm() 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 Index: src/usr.sbin/sysinst/label.c diff -u src/usr.sbin/sysinst/label.c:1.4 src/usr.sbin/sysinst/label.c:1.5 --- src/usr.sbin/sysinst/label.c:1.4 Tue Nov 20 19:02:07 2018 +++ src/usr.sbin/sysinst/label.c Tue Nov 27 17:13:41 2018 @@ -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 @@ set_ptype(partinfo *p, int fstype, int f * >= 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; Index: src/usr.sbin/sysinst/mbr.c diff -u src/usr.sbin/sysinst/mbr.c:1.9 src/usr.sbin/sysinst/mbr.c:1.10 --- src/usr.sbin/sysinst/mbr.c:1.9 Tue Nov 20 19:02:07 2018 +++ src/usr.sbin/sysinst/mbr.c Tue Nov 27 17:13:41 2018 @@ -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 @@ edit_mbr(mbr_info_t *mbri) 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 @@ read_mbr(const char *disk, mbr_info_t *m 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 @@ get_ptn_alignment(struct mbr_partition * } } 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; } Index: src/usr.sbin/sysinst/partman.c diff -u src/usr.sbin/sysinst/partman.c:1.23 src/usr.sbin/sysinst/partman.c:1.24 --- src/usr.sbin/sysinst/partman.c:1.23 Tue Nov 20 19:02:07 2018 +++ src/usr.sbin/sysinst/partman.c Tue Nov 27 17:13:41 2018 @@ -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 @@ pm_menufmt(menudesc *m, int opt, void *a 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 @@ pm_menufmt(menudesc *m, int opt, void *a 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 @@ pm_menufmt(menudesc *m, int opt, void *a 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; Index: src/usr.sbin/sysinst/arch/i386/md.c diff -u src/usr.sbin/sysinst/arch/i386/md.c:1.13 src/usr.sbin/sysinst/arch/i386/md.c:1.14 --- src/usr.sbin/sysinst/arch/i386/md.c:1.13 Sat Sep 15 18:04:21 2018 +++ src/usr.sbin/sysinst/arch/i386/md.c Tue Nov 27 17:13:41 2018 @@ -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 @@ nogeom: 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