summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2004-09-01 05:48:06 +0000
committerscottl <scottl@FreeBSD.org>2004-09-01 05:48:06 +0000
commit6703db134608d1953b911a81784b3e83dcc59e74 (patch)
treeca85a75b39183c91099ae8817abea2672f6adcd0 /sbin
parent0067bbd33a34b1b53ea517ebf1d167b22fd6e37d (diff)
downloadFreeBSD-src-6703db134608d1953b911a81784b3e83dcc59e74.zip
FreeBSD-src-6703db134608d1953b911a81784b3e83dcc59e74.tar.gz
Create DIP_SET() and IBLK_SET() macros to fix lvalue warnings.
Inspired by: kan
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/dir.c28
-rw-r--r--sbin/fsck_ffs/fsck.h15
-rw-r--r--sbin/fsck_ffs/inode.c32
-rw-r--r--sbin/fsck_ffs/pass1.c6
-rw-r--r--sbin/fsck_ffs/pass2.c18
5 files changed, 59 insertions, 40 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index a766c84..a248c27 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -324,7 +324,7 @@ adjust(struct inodesc *idesc, int lcnt)
}
if (preen || reply("ADJUST") == 1) {
if (bkgrdflag == 0) {
- DIP(dp, di_nlink) -= lcnt;
+ DIP_SET(dp, di_nlink, DIP(dp, di_nlink) - lcnt);
inodirty();
} else {
cmd.value = idesc->id_number;
@@ -474,7 +474,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
parentdir != (ino_t)-1)
(void)makeentry(orphan, lfdir, "..");
dp = ginode(lfdir);
- DIP(dp, di_nlink)++;
+ DIP_SET(dp, di_nlink, DIP(dp, di_nlink) + 1);
inodirty();
inoinfo(lfdir)->ino_linkcnt++;
pwarn("DIR I=%lu CONNECTED. ", (u_long)orphan);
@@ -535,7 +535,7 @@ makeentry(ino_t parent, ino_t ino, const char *name)
idesc.id_name = strdup(name);
dp = ginode(parent);
if (DIP(dp, di_size) % DIRBLKSIZ) {
- DIP(dp, di_size) = roundup(DIP(dp, di_size), DIRBLKSIZ);
+ DIP_SET(dp, di_size, roundup(DIP(dp, di_size), DIRBLKSIZ));
inodirty();
}
if ((ckinode(dp, &idesc) & ALTERED) != 0)
@@ -563,10 +563,10 @@ expanddir(union dinode *dp, char *name)
return (0);
if ((newblk = allocblk(sblock.fs_frag)) == 0)
return (0);
- DIP(dp, di_db[lastbn + 1]) = DIP(dp, di_db[lastbn]);
- DIP(dp, di_db[lastbn]) = newblk;
- DIP(dp, di_size) += sblock.fs_bsize;
- DIP(dp, di_blocks) += btodb(sblock.fs_bsize);
+ DIP_SET(dp, di_db[lastbn + 1], DIP(dp, di_db[lastbn]));
+ DIP_SET(dp, di_db[lastbn], newblk);
+ DIP_SET(dp, di_size, DIP(dp, di_size) + sblock.fs_bsize);
+ DIP_SET(dp, di_blocks, DIP(dp, di_blocks) + btodb(sblock.fs_bsize));
bp = getdirblk(DIP(dp, di_db[lastbn + 1]),
sblksize(&sblock, DIP(dp, di_size), lastbn + 1));
if (bp->b_errs)
@@ -595,10 +595,10 @@ expanddir(union dinode *dp, char *name)
inodirty();
return (1);
bad:
- DIP(dp, di_db[lastbn]) = DIP(dp, di_db[lastbn + 1]);
- DIP(dp, di_db[lastbn + 1]) = 0;
- DIP(dp, di_size) -= sblock.fs_bsize;
- DIP(dp, di_blocks) -= btodb(sblock.fs_bsize);
+ DIP_SET(dp, di_db[lastbn], DIP(dp, di_db[lastbn + 1]));
+ DIP_SET(dp, di_db[lastbn + 1], 0);
+ DIP_SET(dp, di_size, DIP(dp, di_size) - sblock.fs_bsize);
+ DIP_SET(dp, di_blocks, DIP(dp, di_blocks) - btodb(sblock.fs_bsize));
freeblk(newblk, sblock.fs_frag);
return (0);
}
@@ -632,7 +632,7 @@ allocdir(ino_t parent, ino_t request, int mode)
cp += DIRBLKSIZ)
memmove(cp, &emptydir, sizeof emptydir);
dirty(bp);
- DIP(dp, di_nlink) = 2;
+ DIP_SET(dp, di_nlink, 2);
inodirty();
if (ino == ROOTINO) {
inoinfo(ino)->ino_linkcnt = DIP(dp, di_nlink);
@@ -654,7 +654,7 @@ allocdir(ino_t parent, ino_t request, int mode)
inoinfo(parent)->ino_linkcnt++;
}
dp = ginode(parent);
- DIP(dp, di_nlink)++;
+ DIP_SET(dp, di_nlink, DIP(dp, di_nlink) + 1);
inodirty();
return (ino);
}
@@ -669,7 +669,7 @@ freedir(ino_t ino, ino_t parent)
if (ino != parent) {
dp = ginode(parent);
- DIP(dp, di_nlink)--;
+ DIP_SET(dp, di_nlink, DIP(dp, di_nlink) - 1);
inodirty();
}
freeino(ino);
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 1763fa1..b654249 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -56,6 +56,13 @@ union dinode {
((sblock.fs_magic == FS_UFS1_MAGIC) ? \
(dp)->dp1.field : (dp)->dp2.field)
+#define DIP_SET(dp, field, val) do { \
+ if (sblock.fs_magic == FS_UFS1_MAGIC) \
+ (dp)->dp1.field = (val); \
+ else \
+ (dp)->dp2.field = (val); \
+ } while (0)
+
/*
* Each inode on the file system is described by the following structure.
* The linkcnt is initially set to the value in the inode. Each time it
@@ -107,10 +114,18 @@ struct bufarea {
} b_un;
char b_dirty;
};
+
#define IBLK(bp, i) \
((sblock.fs_magic == FS_UFS1_MAGIC) ? \
(bp)->b_un.b_indir1[i] : (bp)->b_un.b_indir2[i])
+#define IBLK_SET(bp, i, val) do { \
+ if (sblock.fs_magic == FS_UFS1_MAGIC) \
+ (bp)->b_un.b_indir1[i] = (val); \
+ else \
+ (bp)->b_un.b_indir2[i] = (val); \
+ } while (0)
+
#define B_INUSE 1
#define MINBUFS 5 /* minimum number of buffers required */
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 320450e..729f25e 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -95,7 +95,8 @@ ckinode(union dinode *dp, struct inodesc *idesc)
pathbuf);
if (reply("ADJUST LENGTH") == 1) {
dp = ginode(idesc->id_number);
- DIP(dp, di_size) = i * sblock.fs_bsize;
+ DIP_SET(dp, di_size,
+ i * sblock.fs_bsize);
printf(
"YOU MUST RERUN FSCK AFTERWARDS\n");
rerun = 1;
@@ -133,7 +134,8 @@ ckinode(union dinode *dp, struct inodesc *idesc)
pathbuf);
if (reply("ADJUST LENGTH") == 1) {
dp = ginode(idesc->id_number);
- DIP(dp, di_size) -= remsize;
+ DIP_SET(dp, di_size,
+ DIP(dp, di_size) - remsize);
remsize = 0;
printf(
"YOU MUST RERUN FSCK AFTERWARDS\n");
@@ -183,7 +185,7 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize)
if (preen) {
pfatal("%s", buf);
} else if (dofix(idesc, buf)) {
- IBLK(bp, i) = 0;
+ IBLK_SET(bp, i, 0);
dirty(bp);
}
}
@@ -211,7 +213,8 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize)
pathbuf);
if (reply("ADJUST LENGTH") == 1) {
dp = ginode(idesc->id_number);
- DIP(dp, di_size) -= isize;
+ DIP_SET(dp, di_size,
+ DIP(dp, di_size) - isize);
isize = 0;
printf(
"YOU MUST RERUN FSCK AFTERWARDS\n");
@@ -630,20 +633,21 @@ allocino(ino_t request, int type)
}
cgdirty();
dp = ginode(ino);
- DIP(dp, di_db[0]) = allocblk((long)1);
+ DIP_SET(dp, di_db[0], allocblk((long)1));
if (DIP(dp, di_db[0]) == 0) {
inoinfo(ino)->ino_state = USTATE;
return (0);
}
- DIP(dp, di_mode) = type;
- DIP(dp, di_flags) = 0;
- DIP(dp, di_atime) = time(NULL);
- DIP(dp, di_mtime) = DIP(dp, di_ctime) = DIP(dp, di_atime);
- DIP(dp, di_mtimensec) = 0;
- DIP(dp, di_ctimensec) = 0;
- DIP(dp, di_atimensec) = 0;
- DIP(dp, di_size) = sblock.fs_fsize;
- DIP(dp, di_blocks) = btodb(sblock.fs_fsize);
+ DIP_SET(dp, di_mode, type);
+ DIP_SET(dp, di_flags, 0);
+ DIP_SET(dp, di_atime, time(NULL));
+ DIP_SET(dp, di_ctime, DIP(dp, di_atime));
+ DIP_SET(dp, di_mtime, DIP(dp, di_ctime));
+ DIP_SET(dp, di_mtimensec, 0);
+ DIP_SET(dp, di_ctimensec, 0);
+ DIP_SET(dp, di_atimensec, 0);
+ DIP_SET(dp, di_size, sblock.fs_fsize);
+ DIP_SET(dp, di_blocks, btodb(sblock.fs_fsize));
n_files++;
inodirty();
inoinfo(ino)->ino_type = IFTODT(type);
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index 898f897..b4b3617 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -236,8 +236,8 @@ checkinode(ino_t inumber, struct inodesc *idesc)
}
if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
dp = ginode(inumber);
- DIP(dp, di_size) = sblock.fs_fsize;
- DIP(dp, di_mode) = IFREG|0600;
+ DIP_SET(dp, di_size, sblock.fs_fsize);
+ DIP_SET(dp, di_mode, IFREG|0600);
inodirty();
}
if ((mode == IFBLK || mode == IFCHR || mode == IFIFO ||
@@ -364,7 +364,7 @@ checkinode(ino_t inumber, struct inodesc *idesc)
return;
if (bkgrdflag == 0) {
dp = ginode(inumber);
- DIP(dp, di_blocks) = idesc->id_entryno;
+ DIP_SET(dp, di_blocks, idesc->id_entryno);
inodirty();
} else {
cmd.value = idesc->id_number;
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 353d6ad..096da92 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -103,8 +103,8 @@ pass2(void)
exit(EEXIT);
}
dp = ginode(ROOTINO);
- DIP(dp, di_mode) &= ~IFMT;
- DIP(dp, di_mode) |= IFDIR;
+ DIP_SET(dp, di_mode, DIP(dp, di_mode) & ~IFMT);
+ DIP_SET(dp, di_mode, DIP(dp, di_mode) | IFDIR);
inodirty();
break;
@@ -149,7 +149,7 @@ pass2(void)
inp->i_isize = roundup(MINDIRSIZE, DIRBLKSIZ);
if (reply("FIX") == 1) {
dp = ginode(inp->i_number);
- DIP(dp, di_size) = inp->i_isize;
+ DIP_SET(dp, di_size, inp->i_isize);
inodirty();
}
} else if ((inp->i_isize & (DIRBLKSIZ - 1)) != 0) {
@@ -167,22 +167,22 @@ pass2(void)
inp->i_isize = roundup(inp->i_isize, DIRBLKSIZ);
if (preen || reply("ADJUST") == 1) {
dp = ginode(inp->i_number);
- DIP(dp, di_size) =
- roundup(inp->i_isize, DIRBLKSIZ);
+ DIP_SET(dp, di_size,
+ roundup(inp->i_isize, DIRBLKSIZ));
inodirty();
}
}
dp = &dino;
memset(dp, 0, sizeof(struct ufs2_dinode));
- DIP(dp, di_mode) = IFDIR;
- DIP(dp, di_size) = inp->i_isize;
+ DIP_SET(dp, di_mode, IFDIR);
+ DIP_SET(dp, di_size, inp->i_isize);
for (i = 0;
i < (inp->i_numblks<NDADDR ? inp->i_numblks : NDADDR);
i++)
- DIP(dp, di_db[i]) = inp->i_blks[i];
+ DIP_SET(dp, di_db[i], inp->i_blks[i]);
if (inp->i_numblks > NDADDR)
for (i = 0; i < NIADDR; i++)
- DIP(dp, di_ib[i]) = inp->i_blks[NDADDR + i];
+ DIP_SET(dp, di_ib[i], inp->i_blks[NDADDR + i]);
curino.id_number = inp->i_number;
curino.id_parent = inp->i_parent;
(void)ckinode(dp, &curino);
OpenPOWER on IntegriCloud