summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2023-03-04 21:22:52 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2023-03-04 21:22:52 +0000
commit5fecbfad14b2f80ed49e4967b88a215ed982df96 (patch)
tree79ff97b5b5098e68f4303f8a7aa5ce3b7e205ffe /sbin
parent681f8a8571f69a1b37120d29c6c386c43777fac2 (diff)
Use nitems() in the simple iterations over mbr->mbr_prt[].
No intentional functional change.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/cmd.c8
-rw-r--r--sbin/fdisk/mbr.c8
-rw-r--r--sbin/fdisk/user.c6
3 files changed, 11 insertions, 11 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 7a9aeec1000..014852b8014 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.166 2023/03/04 14:47:18 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.167 2023/03/04 21:22:51 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -385,9 +385,9 @@ Xprint(const char *args, struct mbr *mbr)
int
Xwrite(const char *args, struct mbr *mbr)
{
- int i, n;
+ unsigned int i, n;
- for (i = 0, n = 0; i < NDOSPART; i++)
+ for (i = 0, n = 0; i < nitems(mbr->mbr_prt); i++)
if (mbr->mbr_prt[i].prt_id == DOSPTYP_OPENBSD)
n++;
if (n > 1) {
@@ -493,7 +493,7 @@ Xflag(const char *args, struct mbr *mbr)
gp[i].gp_attrs = 0;
}
} else {
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < nitems(mbr->mbr_prt); i++) {
if (i == pn)
mbr->mbr_prt[i].prt_flag = DOSACTIVE;
else
diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c
index 6e6b6c58caf..ef88ed4cb4a 100644
--- a/sbin/fdisk/mbr.c
+++ b/sbin/fdisk/mbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbr.c,v 1.121 2022/07/26 14:30:37 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.122 2023/03/04 21:22:51 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -145,7 +145,7 @@ mbr_to_dos_mbr(const struct mbr *mbr, struct dos_mbr *dos_mbr)
void
MBR_print(const struct mbr *mbr, const char *units)
{
- int i;
+ unsigned int i;
DISK_printgeometry("s");
@@ -153,7 +153,7 @@ MBR_print(const struct mbr *mbr, const char *units)
printf("Signature: 0x%X\n", (int)mbr->mbr_signature);
PRT_print_parthdr();
- for (i = 0; i < NDOSPART; i++)
+ for (i = 0; i < nitems(mbr->mbr_prt); i++)
PRT_print_part(i, &mbr->mbr_prt[i], units);
}
@@ -198,7 +198,7 @@ MBR_valid_prt(const struct mbr *mbr)
return 1; /* All zeros struct dos_mbr is editable. */
nprt = 0;
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < nitems(mbr->mbr_prt); i++) {
bs = mbr->mbr_prt[i].prt_bs;
ns = mbr->mbr_prt[i].prt_ns;
id = mbr->mbr_prt[i].prt_id;
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c
index f4389ab18e6..27821fe263b 100644
--- a/sbin/fdisk/user.c
+++ b/sbin/fdisk/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.84 2022/07/25 17:45:16 krw Exp $ */
+/* $OpenBSD: user.c,v 1.85 2023/03/04 21:22:51 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -117,7 +117,7 @@ USER_print_disk(const int verbosity)
{
struct mbr mbr;
uint64_t lba_self, lba_firstembr;
- int i;
+ unsigned int i;
lba_self = lba_firstembr = 0;
@@ -160,7 +160,7 @@ USER_print_disk(const int verbosity)
MBR_print(&mbr, "s");
- for (lba_self = i = 0; i < 4; i++)
+ for (lba_self = i = 0; i < nitems(mbr.mbr_prt); i++)
if (mbr.mbr_prt[i].prt_id == DOSPTYP_EXTEND ||
mbr.mbr_prt[i].prt_id == DOSPTYP_EXTENDL) {
lba_self = mbr.mbr_prt[i].prt_bs;