msdosfs: clusterfree() is used only in error handling cases

Change its return type to void, because its result is ignored in both
call sites.  Remove oldcnp argument as well, it is NULL always.

Suggested and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
This commit is contained in:
Konstantin Belousov 2022-01-04 16:43:02 +02:00
parent aec97963cd
commit 65990b68a2
5 changed files with 13 additions and 19 deletions

View File

@ -97,7 +97,7 @@
#define DE_CLEAR 1 /* Zero out the blocks allocated */
int pcbmap(struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int* sp);
int clusterfree(struct msdosfsmount *pmp, u_long cn, u_long *oldcnp);
void clusterfree(struct msdosfsmount *pmp, u_long cn);
int clusteralloc(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith, u_long *retcluster, u_long *got);
int fatentry(int function, struct msdosfsmount *pmp, u_long cluster, u_long *oldcontents, u_long newcontents);
int freeclusterchain(struct msdosfsmount *pmp, u_long startchain);

View File

@ -420,15 +420,15 @@ usemap_free(struct msdosfsmount *pmp, u_long cn)
return (0);
}
int
clusterfree(struct msdosfsmount *pmp, u_long cluster, u_long *oldcnp)
void
clusterfree(struct msdosfsmount *pmp, u_long cluster)
{
int error;
u_long oldcn;
error = fatentry(FAT_GET_AND_SET, pmp, cluster, &oldcn, MSDOSFSFREE);
if (error)
return (error);
if (error != 0)
return;
/*
* If the cluster was successfully marked free, then update
* the count of free clusters, and turn off the "allocated"
@ -437,9 +437,6 @@ clusterfree(struct msdosfsmount *pmp, u_long cluster, u_long *oldcnp)
MSDOSFS_LOCK_MP(pmp);
error = usemap_free(pmp, cluster);
MSDOSFS_UNLOCK_MP(pmp);
if (error == 0 && oldcnp != NULL)
*oldcnp = oldcn;
return (error);
}
/*
@ -1056,7 +1053,7 @@ extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp,
dep->de_fc[FC_LASTFC].fc_fsrcn,
0, cn);
if (error) {
clusterfree(pmp, cn, NULL);
clusterfree(pmp, cn);
return (error);
}
frcn = dep->de_fc[FC_LASTFC].fc_frcn + 1;

View File

@ -1433,7 +1433,7 @@ msdosfs_mkdir(struct vop_mkdir_args *ap)
return (0);
bad:
clusterfree(pmp, newcluster, NULL);
clusterfree(pmp, newcluster);
bad2:
return (error);
}

View File

@ -408,24 +408,21 @@ usemap_free(struct msdosfsmount *pmp, u_long cn)
pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS));
}
int
clusterfree(struct msdosfsmount *pmp, u_long cluster, u_long *oldcnp)
void
clusterfree(struct msdosfsmount *pmp, u_long cluster)
{
int error;
u_long oldcn;
error = fatentry(FAT_GET_AND_SET, pmp, cluster, &oldcn, MSDOSFSFREE);
if (error)
return (error);
if (error != 0)
return;
/*
* If the cluster was successfully marked free, then update
* the count of free clusters, and turn off the "allocated"
* bit in the "in use" cluster bit map.
*/
usemap_free(pmp, cluster);
if (oldcnp)
*oldcnp = oldcn;
return (0);
}
/*
@ -1024,7 +1021,7 @@ m_extendfile(struct denode *dep, u_long count, struct m_buf **bpp, u_long *ncp,
dep->de_fc[FC_LASTFC].fc_fsrcn,
0, cn);
if (error) {
clusterfree(pmp, cn, NULL);
clusterfree(pmp, cn);
return (error);
}
frcn = dep->de_fc[FC_LASTFC].fc_frcn + 1;

View File

@ -636,7 +636,7 @@ msdosfs_mkdire(const char *path, struct denode *pdep, fsnode *node) {
return dep;
bad:
clusterfree(pmp, newcluster, NULL);
clusterfree(pmp, newcluster);
bad2:
errno = error;
return NULL;