Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jan 2022 00:51:41 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: c1df4eef1285 - stable/13 - msdosfs: clusterfree() is used only in error handling cases
Message-ID:  <202201150051.20F0pfmY031199@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=c1df4eef1285793dc9b7c80296e771c55e86cdab

commit c1df4eef1285793dc9b7c80296e771c55e86cdab
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-04 14:43:02 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-14 18:11:02 +0000

    msdosfs: clusterfree() is used only in error handling cases
    
    (cherry picked from commit 65990b68a2cd89a08f0350e187df1968b16f4255)
---
 sys/fs/msdosfs/fat.h                  |  2 +-
 sys/fs/msdosfs/msdosfs_fat.c          | 13 +++++--------
 sys/fs/msdosfs/msdosfs_vnops.c        |  2 +-
 usr.sbin/makefs/msdos/msdosfs_fat.c   | 13 +++++--------
 usr.sbin/makefs/msdos/msdosfs_vnops.c |  2 +-
 5 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/sys/fs/msdosfs/fat.h b/sys/fs/msdosfs/fat.h
index bb0f128eaa87..b28a9bed1356 100644
--- a/sys/fs/msdosfs/fat.h
+++ b/sys/fs/msdosfs/fat.h
@@ -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);
diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c
index 202feeef0102..fc1db705989b 100644
--- a/sys/fs/msdosfs/msdosfs_fat.c
+++ b/sys/fs/msdosfs/msdosfs_fat.c
@@ -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;
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index d64dcf4266bb..58f7f2876523 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -1433,7 +1433,7 @@ msdosfs_mkdir(struct vop_mkdir_args *ap)
 	return (0);
 
 bad:
-	clusterfree(pmp, newcluster, NULL);
+	clusterfree(pmp, newcluster);
 bad2:
 	return (error);
 }
diff --git a/usr.sbin/makefs/msdos/msdosfs_fat.c b/usr.sbin/makefs/msdos/msdosfs_fat.c
index eacc448b09de..63410b8b7d1f 100644
--- a/usr.sbin/makefs/msdos/msdosfs_fat.c
+++ b/usr.sbin/makefs/msdos/msdosfs_fat.c
@@ -410,24 +410,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 @@ 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;
diff --git a/usr.sbin/makefs/msdos/msdosfs_vnops.c b/usr.sbin/makefs/msdos/msdosfs_vnops.c
index 8bd4d3d498d8..6f1275ee125d 100644
--- a/usr.sbin/makefs/msdos/msdosfs_vnops.c
+++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c
@@ -637,7 +637,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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201150051.20F0pfmY031199>