git: 1a35d94bbbc5 - stable/13 - mountmsdosfs(): some style
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 09 Jan 2022 01:20:54 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1a35d94bbbc5197b555f7b406737bba4f3e4ef74 commit 1a35d94bbbc5197b555f7b406737bba4f3e4ef74 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-12-30 19:33:41 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-01-09 01:20:22 +0000 mountmsdosfs(): some style (cherry picked from commit 04fd468da0d0baea535da418b92df74101a9659d) --- sys/fs/msdosfs/msdosfs_vfsops.c | 55 +++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 0f6d41b3c77c..939badf458fb 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -456,14 +456,14 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB; #ifndef MSDOSFS_NOCHECKSIG - if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 - || bsp->bs50.bsBootSectSig1 != BOOTSIG1) { + if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 || + bsp->bs50.bsBootSectSig1 != BOOTSIG1) { error = EINVAL; goto error_exit; } #endif - pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK | M_ZERO); + pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK | M_ZERO); pmp->pm_mountp = mp; pmp->pm_cp = cp; pmp->pm_bo = bo; @@ -509,7 +509,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) * use these anyway, so we're unaffected if they are * invalid. */ - if (!pmp->pm_BytesPerSec || !SecPerClust) { + if (pmp->pm_BytesPerSec == 0 || SecPerClust == 0) { error = EINVAL; goto error_exit; } @@ -523,8 +523,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) } if (pmp->pm_RootDirEnts == 0) { - if (pmp->pm_FATsecs - || getushort(b710->bpbFSVers)) { + if (pmp->pm_FATsecs != 0 || getushort(b710->bpbFSVers) != 0) { error = EINVAL; #ifdef MSDOSFS_DEBUG printf("mountmsdosfs(): bad FAT32 filesystem\n"); @@ -535,7 +534,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) pmp->pm_fatmult = 4; pmp->pm_fatdiv = 1; pmp->pm_FATsecs = getulong(b710->bpbBigFATsecs); - if (getushort(b710->bpbExtFlags) & FATMIRROR) + if ((getushort(b710->bpbExtFlags) & FATMIRROR) != 0) pmp->pm_curfat = getushort(b710->bpbExtFlags) & FATNUM; else pmp->pm_flags |= MSDOSFS_FATMIRROR; @@ -549,14 +548,11 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) * - number of sectors: >= 1, <= size of partition * - number of FAT sectors: >= 1 */ - if ( (SecPerClust == 0) - || (SecPerClust & (SecPerClust - 1)) - || (pmp->pm_BytesPerSec < DEV_BSIZE) - || (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1)) - || (pmp->pm_HugeSectors == 0) - || (pmp->pm_FATsecs == 0) - || (SecPerClust * pmp->pm_BlkPerSec > MAXBSIZE / DEV_BSIZE) - ) { + if (SecPerClust == 0 || (SecPerClust & (SecPerClust - 1)) != 0 || + pmp->pm_BytesPerSec < DEV_BSIZE || + (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1)) != 0 || + pmp->pm_HugeSectors == 0 || pmp->pm_FATsecs == 0 || + SecPerClust * pmp->pm_BlkPerSec > MAXBSIZE / DEV_BSIZE) { error = EINVAL; goto error_exit; } @@ -570,14 +566,14 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) if (FAT32(pmp)) { pmp->pm_rootdirblk = getulong(b710->bpbRootClust); - pmp->pm_firstcluster = pmp->pm_fatblk - + (pmp->pm_FATs * pmp->pm_FATsecs); + pmp->pm_firstcluster = pmp->pm_fatblk + + pmp->pm_FATs * pmp->pm_FATsecs; pmp->pm_fsinfo = getushort(b710->bpbFSInfo) * pmp->pm_BlkPerSec; } else { pmp->pm_rootdirblk = pmp->pm_fatblk + - (pmp->pm_FATs * pmp->pm_FATsecs); + pmp->pm_FATs * pmp->pm_FATsecs; pmp->pm_rootdirsize = howmany(pmp->pm_RootDirEnts * - sizeof(struct direntry), DEV_BSIZE); /* in blocks */ + sizeof(struct direntry), DEV_BSIZE); /* in blocks */ pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize; } @@ -586,8 +582,8 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */ if (pmp->pm_fatmask == 0) { - if (pmp->pm_maxcluster - <= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) { + if (pmp->pm_maxcluster <= ((CLUST_RSRVD - CLUST_FIRST) & + FAT12_MASK)) { /* * This will usually be a floppy disk. This size makes * sure that one FAT entry will not be split across @@ -633,7 +629,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) * Check for valid cluster size * must be a power of 2 */ - if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) { + if ((pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) != 0) { error = EINVAL; goto error_exit; } @@ -657,9 +653,9 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) NOCRED, &bp)) != 0) goto error_exit; fp = (struct fsinfo *)bp->b_data; - if (!bcmp(fp->fsisig1, "RRaA", 4) - && !bcmp(fp->fsisig2, "rrAa", 4) - && !bcmp(fp->fsisig3, "\0\0\125\252", 4)) { + if (!bcmp(fp->fsisig1, "RRaA", 4) && + !bcmp(fp->fsisig2, "rrAa", 4) && + !bcmp(fp->fsisig3, "\0\0\125\252", 4)) { pmp->pm_nxtfree = getulong(fp->fsinxtfree); if (pmp->pm_nxtfree > pmp->pm_maxcluster) pmp->pm_nxtfree = CLUST_FIRST; @@ -683,9 +679,8 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) * Allocate memory for the bitmap of allocated clusters, and then * fill it in. */ - pmp->pm_inusemap = malloc(howmany(pmp->pm_maxcluster + 1, N_INUSEBITS) - * sizeof(*pmp->pm_inusemap), - M_MSDOSFSFAT, M_WAITOK); + pmp->pm_inusemap = malloc(howmany(pmp->pm_maxcluster + 1, + N_INUSEBITS) * sizeof(*pmp->pm_inusemap), M_MSDOSFSFAT, M_WAITOK); /* * fillinusemap() needs pm_devvp. @@ -732,14 +727,14 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) return (0); error_exit: - if (bp) + if (bp != NULL) brelse(bp); if (cp != NULL) { g_topology_lock(); g_vfs_close(cp); g_topology_unlock(); } - if (pmp) { + if (pmp != NULL) { lockdestroy(&pmp->pm_fatlock); lockdestroy(&pmp->pm_checkpath_lock); free(pmp->pm_inusemap, M_MSDOSFSFAT);