summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-24 03:11:52 +0000
committerpfg <pfg@FreeBSD.org>2016-04-24 03:11:52 +0000
commit45c43e5430044737ff3b728d409ebacdc269191c (patch)
tree618ba03f619fd3ffda345dfbc6c2358cda2ee04a
parent055dc85d60fa4be6e2d24ddde3d3b57c76d63d17 (diff)
downloadFreeBSD-src-45c43e5430044737ff3b728d409ebacdc269191c.zip
FreeBSD-src-45c43e5430044737ff3b728d409ebacdc269191c.tar.gz
MFC r297791:
UFS: replace 0 with NULL for pointers. While here also do late initialization of the variables we are changing. Found with devel/coccinelle. Reviewed by: mckusick
-rw-r--r--sys/ufs/ffs/ffs_alloc.c11
-rw-r--r--sys/ufs/ffs/ffs_snapshot.c4
-rw-r--r--sys/ufs/ffs/ffs_softdep.c33
-rw-r--r--sys/ufs/ufs/ufs_lookup.c3
4 files changed, 29 insertions, 22 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 958c37e..8969af8 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -259,7 +259,6 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, flags, cred, bpp)
static int curfail;
int64_t delta;
- *bpp = 0;
vp = ITOV(ip);
fs = ip->i_fs;
bp = NULL;
@@ -319,6 +318,7 @@ retry:
/*
* Check for extension in the existing location.
*/
+ *bpp = NULL;
cg = dtog(fs, bprev);
UFS_LOCK(ump);
bno = ffs_fragextend(ip, cg, bprev, osize, nsize);
@@ -508,7 +508,7 @@ ffs_reallocblks_ufs1(ap)
struct inode *ip;
struct vnode *vp;
struct buf *sbp, *ebp;
- ufs1_daddr_t *bap, *sbap, *ebap = 0;
+ ufs1_daddr_t *bap, *sbap, *ebap;
struct cluster_save *buflist;
struct ufsmount *ump;
ufs_lbn_t start_lbn, end_lbn;
@@ -588,6 +588,7 @@ ffs_reallocblks_ufs1(ap)
/*
* If the block range spans two block maps, get the second map.
*/
+ ebap = NULL;
if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
ssize = len;
} else {
@@ -757,7 +758,7 @@ ffs_reallocblks_ufs2(ap)
struct inode *ip;
struct vnode *vp;
struct buf *sbp, *ebp;
- ufs2_daddr_t *bap, *sbap, *ebap = 0;
+ ufs2_daddr_t *bap, *sbap, *ebap;
struct cluster_save *buflist;
struct ufsmount *ump;
ufs_lbn_t start_lbn, end_lbn;
@@ -836,6 +837,7 @@ ffs_reallocblks_ufs2(ap)
/*
* If the block range spans two block maps, get the second map.
*/
+ ebap = NULL;
if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
ssize = len;
} else {
@@ -2774,7 +2776,8 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
return (EINVAL);
}
vn_start_write(vp, &mp, V_WAIT);
- if (mp == 0 || strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN)) {
+ if (mp == NULL ||
+ strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN)) {
vn_finished_write(mp);
fdrop(fp, td);
return (EINVAL);
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index 099faeb..59ae322 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -1896,7 +1896,7 @@ retry:
* dopersistence sysctl-setable flag to decide on the
* persistence needed for file content data.
*/
- if (savedcbp != 0) {
+ if (savedcbp != NULL) {
bcopy(savedcbp->b_data, cbp->b_data, fs->fs_bsize);
bawrite(cbp);
if ((vtype == VDIR || dopersistence) &&
@@ -2388,7 +2388,7 @@ ffs_copyonwrite(devvp, bp)
* dopersistence sysctl-setable flag to decide on the
* persistence needed for file content data.
*/
- if (savedcbp != 0) {
+ if (savedcbp != NULL) {
bcopy(savedcbp->b_data, cbp->b_data, fs->fs_bsize);
bawrite(cbp);
if ((devvp == bp->b_vp || bp->b_vp->v_type == VDIR ||
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index fece706..58ef6dc 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -1868,7 +1868,7 @@ softdep_move_dependencies(oldbp, newbp)
if (wk->wk_type == D_BMSAFEMAP &&
bmsafemap_backgroundwrite(WK_BMSAFEMAP(wk), newbp))
dirty = 1;
- if (wktail == 0)
+ if (wktail == NULL)
LIST_INSERT_HEAD(&newbp->b_dep, wk, wk_list);
else
LIST_INSERT_AFTER(wktail, wk, wk_list);
@@ -6667,7 +6667,7 @@ softdep_journal_freeblocks(ip, cred, length, flags)
}
}
if ((flags & IO_EXT) != 0)
- while ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != 0)
+ while ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != NULL)
cancel_allocdirect(&inodedep->id_extupdt, adp,
freeblks);
/*
@@ -6919,14 +6919,14 @@ softdep_setup_freeblocks(ip, length, flags)
if (flags & IO_NORMAL) {
merge_inode_lists(&inodedep->id_newinoupdt,
&inodedep->id_inoupdt);
- while ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != 0)
+ while ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != NULL)
cancel_allocdirect(&inodedep->id_inoupdt, adp,
freeblks);
}
if (flags & IO_EXT) {
merge_inode_lists(&inodedep->id_newextupdt,
&inodedep->id_extupdt);
- while ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != 0)
+ while ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != NULL)
cancel_allocdirect(&inodedep->id_extupdt, adp,
freeblks);
}
@@ -8041,8 +8041,8 @@ indir_trunc(freework, dbn, lbn)
struct fs *fs;
struct indirdep *indirdep;
struct ufsmount *ump;
- ufs1_daddr_t *bap1 = 0;
- ufs2_daddr_t nb, nnb, *bap2 = 0;
+ ufs1_daddr_t *bap1;
+ ufs2_daddr_t nb, nnb, *bap2;
ufs_lbn_t lbnadd, nlbn;
int i, nblocks, ufs1fmt;
int freedblocks;
@@ -8125,10 +8125,12 @@ indir_trunc(freework, dbn, lbn)
bap1 = (ufs1_daddr_t *)bp->b_data;
nb = bap1[freework->fw_off];
ufs1fmt = 1;
+ bap2 = NULL;
} else {
bap2 = (ufs2_daddr_t *)bp->b_data;
nb = bap2[freework->fw_off];
ufs1fmt = 0;
+ bap1 = NULL;
}
level = lbn_level(lbn);
needj = MOUNTEDSUJ(UFSTOVFS(ump)) != 0;
@@ -8303,7 +8305,7 @@ setup_newdir(dap, newinum, dinum, newdirbp, mkdirp)
struct newblk *newblk;
struct pagedep *pagedep;
struct inodedep *inodedep;
- struct newdirblk *newdirblk = 0;
+ struct newdirblk *newdirblk;
struct mkdir *mkdir1, *mkdir2;
struct worklist *wk;
struct jaddref *jaddref;
@@ -8430,7 +8432,7 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk)
struct newblk *newblk;
struct pagedep *pagedep;
struct inodedep *inodedep;
- struct newdirblk *newdirblk = 0;
+ struct newdirblk *newdirblk;
struct mkdir *mkdir1, *mkdir2;
struct jaddref *jaddref;
struct ufsmount *ump;
@@ -8462,6 +8464,7 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk)
dap->da_state = ATTACHED;
LIST_INIT(&dap->da_jwork);
isindir = bp->b_lblkno >= NDADDR;
+ newdirblk = NULL;
if (isnewblk &&
(isindir ? blkoff(fs, diroffset) : fragoff(fs, diroffset)) == 0) {
newdirblk = malloc(sizeof(struct newdirblk),
@@ -8552,7 +8555,7 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk)
inodedep->id_mkdiradd = dap;
} else if (inodedep->id_mkdiradd)
merge_diradd(inodedep, dap);
- if (newdirblk) {
+ if (newdirblk != NULL) {
/*
* There is nothing to do if we are already tracking
* this block.
@@ -10529,13 +10532,13 @@ cancel_indirdep(indirdep, bp, freeblks)
* Pass in bp for blocks still have journal writes
* pending so we can cancel them on their own.
*/
- while ((aip = LIST_FIRST(&indirdep->ir_deplisthd)) != 0)
+ while ((aip = LIST_FIRST(&indirdep->ir_deplisthd)) != NULL)
cancel_allocindir(aip, bp, freeblks, 0);
- while ((aip = LIST_FIRST(&indirdep->ir_donehd)) != 0)
+ while ((aip = LIST_FIRST(&indirdep->ir_donehd)) != NULL)
cancel_allocindir(aip, NULL, freeblks, 0);
- while ((aip = LIST_FIRST(&indirdep->ir_writehd)) != 0)
+ while ((aip = LIST_FIRST(&indirdep->ir_writehd)) != NULL)
cancel_allocindir(aip, NULL, freeblks, 0);
- while ((aip = LIST_FIRST(&indirdep->ir_completehd)) != 0)
+ while ((aip = LIST_FIRST(&indirdep->ir_completehd)) != NULL)
cancel_allocindir(aip, NULL, freeblks, 0);
/*
* If there are pending partial truncations we need to keep the
@@ -11565,7 +11568,7 @@ handle_written_indirdep(indirdep, bp, bpp)
* the indirdep's pointer is not yet written. Otherwise
* free them here.
*/
- while ((aip = LIST_FIRST(&indirdep->ir_writehd)) != 0) {
+ while ((aip = LIST_FIRST(&indirdep->ir_writehd)) != NULL) {
LIST_REMOVE(aip, ai_next);
if ((indirdep->ir_state & DEPCOMPLETE) == 0) {
LIST_INSERT_HEAD(&indirdep->ir_completehd, aip,
@@ -11580,7 +11583,7 @@ handle_written_indirdep(indirdep, bp, bpp)
* the done list to the write list after updating the pointers.
*/
if (TAILQ_EMPTY(&indirdep->ir_trunc)) {
- while ((aip = LIST_FIRST(&indirdep->ir_donehd)) != 0) {
+ while ((aip = LIST_FIRST(&indirdep->ir_donehd)) != NULL) {
handle_allocindir_partdone(aip);
if (aip == LIST_FIRST(&indirdep->ir_donehd))
panic("disk_write_complete: not gone");
diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c
index b9955f1..85ab35a 100644
--- a/sys/ufs/ufs/ufs_lookup.c
+++ b/sys/ufs/ufs/ufs_lookup.c
@@ -1256,7 +1256,8 @@ out:
* drop its snapshot reference so that it will be reclaimed
* when last open reference goes away.
*/
- if (ip != 0 && (ip->i_flags & SF_SNAPSHOT) != 0 && ip->i_effnlink == 0)
+ if (ip != NULL && (ip->i_flags & SF_SNAPSHOT) != 0 &&
+ ip->i_effnlink == 0)
UFS_SNAPGONE(ip);
return (error);
}
OpenPOWER on IntegriCloud