summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2023-07-05 10:59:08 +0000
committerriastradh <riastradh@NetBSD.org>2023-07-05 10:59:08 +0000
commit64569d51e15b41306c0429824946898faac75519 (patch)
treecac7cbce56cad6267ff86d705819b559772d1731
parentfb5ff443eb2cd1f7888a14d2f1f5c8016d27073c (diff)
Revert "fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S)."
C17 lifted this restriction.
-rw-r--r--sbin/fsck_ffs/inode.c8
-rw-r--r--sbin/fsck_ffs/setup.c16
-rw-r--r--sbin/fsck_ffs/utilities.c13
3 files changed, 12 insertions, 25 deletions
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 71e91ab95ee..5729aad53eb 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.77 2023/07/04 20:40:53 riastradh Exp $ */
+/* $NetBSD: inode.c,v 1.78 2023/07/05 10:59:08 riastradh Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: inode.c,v 1.77 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: inode.c,v 1.78 2023/07/05 10:59:08 riastradh Exp $");
#endif
#endif /* not lint */
@@ -462,10 +462,8 @@ setinodebuf(ino_t inum)
partialcnt = fullcnt;
partialsize = inobufsize;
}
- __CTASSERT(powerof2(DEV_BSIZE));
if (inodebuf == NULL &&
- (inodebuf = aligned_alloc(DEV_BSIZE,
- roundup2((unsigned)inobufsize, DEV_BSIZE))) == NULL)
+ (inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
errexit("Cannot allocate space for inode buffer");
}
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index d071243ff42..bccec933c41 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.108 2023/07/04 20:40:53 riastradh Exp $ */
+/* $NetBSD: setup.c,v 1.109 2023/07/05 10:59:08 riastradh Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
#else
-__RCSID("$NetBSD: setup.c,v 1.108 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: setup.c,v 1.109 2023/07/05 10:59:08 riastradh Exp $");
#endif
#endif /* not lint */
@@ -127,7 +127,6 @@ setup(const char *dev, const char *origdev)
lfdir = 0;
initbarea(&sblk);
initbarea(&asblk);
- __CTASSERT((SBLOCKSIZE % DEV_BSIZE) == 0);
sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
@@ -460,9 +459,8 @@ setup(const char *dev, const char *origdev)
* read in the summary info.
*/
asked = 0;
- __CTASSERT(powerof2(DEV_BSIZE));
sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
- roundup2(sblock->fs_cssize, DEV_BSIZE));
+ sblock->fs_cssize);
if (sblock->fs_csp == NULL) {
pwarn("cannot alloc %u bytes for summary info\n",
sblock->fs_cssize);
@@ -497,9 +495,7 @@ setup(const char *dev, const char *origdev)
* allocate and initialize the necessary maps
*/
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
- __CTASSERT(powerof2(DEV_BSIZE));
- blockmap = aligned_alloc(DEV_BSIZE,
- roundup2((unsigned)bmapsize, DEV_BSIZE));
+ blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
if (blockmap == NULL) {
pwarn("cannot alloc %u bytes for blockmap\n",
(unsigned)bmapsize);
@@ -534,9 +530,7 @@ setup(const char *dev, const char *origdev)
(unsigned)(numdirs * sizeof(struct inoinfo *)));
goto badsblabel;
}
- __CTASSERT(powerof2(DEV_BSIZE));
- cgrp = aligned_alloc(DEV_BSIZE,
- roundup2(sblock->fs_cgsize, DEV_BSIZE));
+ cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
if (cgrp == NULL) {
pwarn("cannot alloc %u bytes for cylinder group\n",
sblock->fs_cgsize);
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index aac3d5f02e4..544574a3849 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -1,4 +1,4 @@
-/* $NetBSD: utilities.c,v 1.70 2023/07/04 20:40:53 riastradh Exp $ */
+/* $NetBSD: utilities.c,v 1.71 2023/07/05 10:59:08 riastradh Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
#else
-__RCSID("$NetBSD: utilities.c,v 1.70 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.71 2023/07/05 10:59:08 riastradh Exp $");
#endif
#endif /* not lint */
@@ -135,15 +135,12 @@ bufinit(void)
char *bufp;
pbp = pdirbp = (struct bufarea *)0;
- __CTASSERT(powerof2(DEV_BSIZE));
- bufp = aligned_alloc(DEV_BSIZE,
- roundup2((unsigned int)sblock->fs_bsize, DEV_BSIZE));
+ bufp = aligned_alloc(DEV_BSIZE, (unsigned int)sblock->fs_bsize);
if (bufp == 0)
errexit("cannot allocate buffer pool");
cgblk.b_un.b_buf = bufp;
initbarea(&cgblk);
#ifndef NO_APPLE_UFS
- __CTASSERT((APPLEUFS_LABEL_SIZE % DEV_BSIZE) == 0);
bufp = aligned_alloc(DEV_BSIZE, (unsigned int)APPLEUFS_LABEL_SIZE);
if (bufp == 0)
errexit("cannot allocate buffer pool");
@@ -156,9 +153,7 @@ bufinit(void)
bufcnt = MINBUFS;
for (i = 0; i < bufcnt; i++) {
bp = malloc(sizeof(struct bufarea));
- __CTASSERT(powerof2(DEV_BSIZE));
- bufp = aligned_alloc(DEV_BSIZE,
- roundup2((unsigned int)sblock->fs_bsize, DEV_BSIZE));
+ bufp = aligned_alloc(DEV_BSIZE, (unsigned int)sblock->fs_bsize);
if (bp == NULL || bufp == NULL) {
if (i >= MINBUFS) {
if (bp)