svn commit: r297791 - in head/sys/ufs: ffs ufs
Pedro F. Giffuni
pfg at FreeBSD.org
Sun Apr 10 21:48:12 UTC 2016
Author: pfg
Date: Sun Apr 10 21:48:11 2016
New Revision: 297791
URL: https://svnweb.freebsd.org/changeset/base/297791
Log:
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
MFC after: 2 weeks
Modified:
head/sys/ufs/ffs/ffs_alloc.c
head/sys/ufs/ffs/ffs_snapshot.c
head/sys/ufs/ffs/ffs_softdep.c
head/sys/ufs/ufs/ufs_lookup.c
Modified: head/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_alloc.c Sun Apr 10 19:33:58 2016 (r297790)
+++ head/sys/ufs/ffs/ffs_alloc.c Sun Apr 10 21:48:11 2016 (r297791)
@@ -259,7 +259,6 @@ ffs_realloccg(ip, lbprev, bprev, bpref,
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);
@@ -518,7 +518,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;
@@ -598,6 +598,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 {
@@ -767,7 +768,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;
@@ -846,6 +847,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 {
@@ -2784,7 +2786,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);
Modified: head/sys/ufs/ffs/ffs_snapshot.c
==============================================================================
--- head/sys/ufs/ffs/ffs_snapshot.c Sun Apr 10 19:33:58 2016 (r297790)
+++ head/sys/ufs/ffs/ffs_snapshot.c Sun Apr 10 21:48:11 2016 (r297791)
@@ -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 ||
Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 19:33:58 2016 (r297790)
+++ head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 21:48:11 2016 (r297791)
@@ -1869,7 +1869,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);
@@ -6675,7 +6675,7 @@ softdep_journal_freeblocks(ip, cred, len
}
}
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);
/*
@@ -6928,14 +6928,14 @@ softdep_setup_freeblocks(ip, length, fla
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);
}
@@ -8050,8 +8050,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;
@@ -8134,10 +8134,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;
@@ -8312,7 +8314,7 @@ setup_newdir(dap, newinum, dinum, newdir
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;
@@ -8439,7 +8441,7 @@ softdep_setup_directory_add(bp, dp, diro
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;
@@ -8471,6 +8473,7 @@ softdep_setup_directory_add(bp, dp, diro
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),
@@ -8561,7 +8564,7 @@ softdep_setup_directory_add(bp, dp, diro
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.
@@ -10538,13 +10541,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
@@ -11574,7 +11577,7 @@ handle_written_indirdep(indirdep, bp, bp
* 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,
@@ -11589,7 +11592,7 @@ handle_written_indirdep(indirdep, bp, bp
* 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");
Modified: head/sys/ufs/ufs/ufs_lookup.c
==============================================================================
--- head/sys/ufs/ufs/ufs_lookup.c Sun Apr 10 19:33:58 2016 (r297790)
+++ head/sys/ufs/ufs/ufs_lookup.c Sun Apr 10 21:48:11 2016 (r297791)
@@ -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);
}
More information about the svn-src-all
mailing list