diff options
Diffstat (limited to 'nuttx/fs/fat')
-rw-r--r-- | nuttx/fs/fat/fs_configfat.c | 14 | ||||
-rw-r--r-- | nuttx/fs/fat/fs_fat32.c | 3 | ||||
-rw-r--r-- | nuttx/fs/fat/fs_fat32util.c | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/nuttx/fs/fat/fs_configfat.c b/nuttx/fs/fat/fs_configfat.c index 2075caa9f..04141ee2b 100644 --- a/nuttx/fs/fat/fs_configfat.c +++ b/nuttx/fs/fat/fs_configfat.c @@ -406,7 +406,7 @@ mkfatfs_clustersearchlimits(FAR struct fat_format_s *fmt, FAR struct fat_var_s * } /**************************************************************************** - * Name: mkfatfs_try12 + * Name: mkfatfs_tryfat12 * * Description: * Try to define a FAT12 filesystem on the device using the candidate @@ -462,7 +462,7 @@ mkfatfs_tryfat12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * FAT12 (remembering that two FAT cluster slots are reserved). */ - if (config->fc_nclusters > maxnclusters - 2) + if (config->fc_nclusters + 2 > maxnclusters) { fvdbg("Too many clusters for FAT12\n"); return -ENFILE; @@ -472,7 +472,7 @@ mkfatfs_tryfat12(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, } /**************************************************************************** - * Name: mkfatfs_try16 + * Name: mkfatfs_tryfat16 * * Description: * Try to define a FAT16 filesystem on the device using the candidate @@ -532,7 +532,7 @@ mkfatfs_tryfat16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * be confused as a FAT12 at mount time. */ - if ((config->fc_nclusters > maxnclusters - 2) || + if ((config->fc_nclusters + 2 > maxnclusters) || (config->fc_nclusters < FAT_MINCLUST16)) { fvdbg("Too few or too many clusters for FAT16\n"); @@ -543,7 +543,7 @@ mkfatfs_tryfat16(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, } /**************************************************************************** - * Name: mkfatfs_try32 + * Name: mkfatfs_tryfat32 * * Description: * Try to define a FAT32 filesystem on the device using the candidate @@ -587,7 +587,7 @@ mkfatfs_tryfat32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * maxnclusters = nfatsects * sectorsize / 4 - 2 */ - maxnclusters = (config->fc_nfatsects >> (var->fv_sectshift - 2)); + maxnclusters = (config->fc_nfatsects << (var->fv_sectshift - 2)); if (maxnclusters > FAT_MAXCLUST32) { maxnclusters = FAT_MAXCLUST32; @@ -599,7 +599,7 @@ mkfatfs_tryfat32(FAR struct fat_format_s *fmt, FAR struct fat_var_s *var, * FAT32 (remembering that two FAT cluster slots are reserved). */ - if ((config->fc_nclusters > maxnclusters - 3) || + if ((config->fc_nclusters + 3 > maxnclusters) || (config->fc_nclusters < FAT_MINCLUST32 && fmt->ff_fattype != 32)) { fvdbg("Too few or too many clusters for FAT32\n"); diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index c10c28a5c..df8962b51 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -381,6 +381,7 @@ static int fat_close(FAR struct file *filep) { struct inode *inode; struct fat_file_s *ff; + struct fat_mountpt_s *fs; int ret = OK; /* Sanity checks */ @@ -391,6 +392,7 @@ static int fat_close(FAR struct file *filep) ff = filep->f_priv; inode = filep->f_inode; + fs = inode->i_private; /* Do not check if the mount is healthy. We must support closing of * the file even when there is healthy mount. @@ -408,6 +410,7 @@ static int fat_close(FAR struct file *filep) if (ff->ff_buffer) { + (void)fs; /* Unused if fat_io_free == free(). */ fat_io_free(ff->ff_buffer, fs->fs_hwsectorsize); } diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index 9aa1d3992..8edef7735 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -106,8 +106,8 @@ static int fat_checkfsinfo(struct fat_mountpt_s *fs) FSI_GETSTRUCTSIG(fs->fs_buffer) == 0x61417272 && FSI_GETTRAILSIG(fs->fs_buffer) == BOOT_SIGNATURE32) { - fs->fs_fsinextfree = FSI_GETFREECOUNT(fs->fs_buffer); - fs->fs_fsifreecount = FSI_GETNXTFREE(fs->fs_buffer); + fs->fs_fsifreecount = FSI_GETFREECOUNT(fs->fs_buffer); + fs->fs_fsinextfree = FSI_GETNXTFREE(fs->fs_buffer); return OK; } } |