mirror of
https://github.com/apache/nuttx.git
synced 2026-09-12 21:50:14 +00:00
fs/fat: fix nxstyle violations flagged by CI
Fix blank-line-after-declarations and switch-case alignment issues in fs/fat files touched by the unlink-while-open change, including pre-existing violations in the same regions. No functional change. Signed-off-by: Arnav Sharma <2006arnavsharma@gmail.com>
This commit is contained in:
parent
8048aa0f81
commit
b13be31798
3 changed files with 59 additions and 28 deletions
|
|
@ -1636,23 +1636,23 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
|
|||
switch (whence)
|
||||
{
|
||||
case SEEK_SET: /* The offset is set to offset bytes. */
|
||||
position = offset;
|
||||
break;
|
||||
position = offset;
|
||||
break;
|
||||
|
||||
case SEEK_CUR: /* The offset is set to its current location plus
|
||||
* offset bytes. */
|
||||
|
||||
position = offset + filep->f_pos;
|
||||
break;
|
||||
position = offset + filep->f_pos;
|
||||
break;
|
||||
|
||||
case SEEK_END: /* The offset is set to the size of the file plus
|
||||
* offset bytes. */
|
||||
|
||||
position = offset + ff->ff_shared->s_size;
|
||||
break;
|
||||
position = offset + ff->ff_shared->s_size;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Invalid arguments are entered, returns an error. */
|
||||
|
|
@ -2159,7 +2159,9 @@ static int fat_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
case FIOC_FILEPATH:
|
||||
{
|
||||
FAR char *path = (FAR char *)(uintptr_t)arg;
|
||||
FAR char *path;
|
||||
|
||||
path = (FAR char *)(uintptr_t)arg;
|
||||
ret = inode_getpath(filep->f_inode, path, PATH_MAX);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
|
@ -3224,7 +3226,9 @@ static int fat_unbind(FAR void *handle, FAR struct inode **blkdriver,
|
|||
|
||||
if (fs->fs_blkdriver)
|
||||
{
|
||||
FAR struct inode *inode = fs->fs_blkdriver;
|
||||
FAR struct inode *inode;
|
||||
|
||||
inode = fs->fs_blkdriver;
|
||||
if (inode)
|
||||
{
|
||||
if (inode->u.i_bops && inode->u.i_bops->close)
|
||||
|
|
|
|||
|
|
@ -775,7 +775,7 @@ static inline int fat_createalias(FAR struct fat_dirinfo_s *dirinfo)
|
|||
}
|
||||
else
|
||||
{
|
||||
src = (FAR lfnchar *)dirinfo->fd_lfname;
|
||||
src = (FAR lfnchar *)dirinfo->fd_lfname;
|
||||
}
|
||||
|
||||
/* Then copy the name and extension, handling upper case conversions and
|
||||
|
|
@ -1163,8 +1163,10 @@ static int fat_path2dirname(FAR const char **path,
|
|||
/* Get short file name for given path */
|
||||
|
||||
char name[DIR_MAXFNAME];
|
||||
FAR const char *tmp;
|
||||
|
||||
memcpy(name, dirinfo->fd_lfname, DIR_MAXFNAME);
|
||||
FAR const char *tmp = (FAR const char *)name;
|
||||
tmp = (FAR const char *)name;
|
||||
if (fat_parsesfname(&tmp, dirinfo, NULL) != OK)
|
||||
{
|
||||
/* The name fits the short form's length but cannot be
|
||||
|
|
@ -2666,7 +2668,9 @@ int fat_finddirentry(FAR struct fat_mountpt_s *fs,
|
|||
* - file created on Windows is written as SFN if it fits 8.3
|
||||
*/
|
||||
|
||||
struct fat_dirinfo_s d = *dirinfo;
|
||||
struct fat_dirinfo_s d;
|
||||
|
||||
d = *dirinfo;
|
||||
ret = fat_findlfnentry(fs, dirinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -549,13 +549,16 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable)
|
|||
*/
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
/* Check if the partition exists and, if so, get the bootsector for
|
||||
* that partition and see if we can find the boot record there.
|
||||
*/
|
||||
|
||||
uint8_t part = PART_GETTYPE(i, fs->fs_buffer);
|
||||
uint8_t part;
|
||||
|
||||
part = PART_GETTYPE(i, fs->fs_buffer);
|
||||
finfo("Partition %d, offset %d, type %d\n",
|
||||
i, PART_ENTRY(i), part);
|
||||
|
||||
|
|
@ -690,11 +693,15 @@ int fat_checkmount(struct fat_mountpt_s *fs)
|
|||
|
||||
if (fs->fs_blkdriver)
|
||||
{
|
||||
struct inode *inode = fs->fs_blkdriver;
|
||||
struct inode *inode;
|
||||
|
||||
inode = fs->fs_blkdriver;
|
||||
if (inode && inode->u.i_bops && inode->u.i_bops->geometry)
|
||||
{
|
||||
struct geometry geo;
|
||||
int errcode = inode->u.i_bops->geometry(inode, &geo);
|
||||
int errcode;
|
||||
|
||||
errcode = inode->u.i_bops->geometry(inode, &geo);
|
||||
if (errcode == OK && geo.geo_available &&
|
||||
!geo.geo_mediachanged)
|
||||
{
|
||||
|
|
@ -722,14 +729,20 @@ int fat_checkmount(struct fat_mountpt_s *fs)
|
|||
int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
|
||||
unsigned int nsectors)
|
||||
{
|
||||
int ret = -ENODEV;
|
||||
int ret;
|
||||
|
||||
ret = -ENODEV;
|
||||
if (fs && fs->fs_blkdriver)
|
||||
{
|
||||
struct inode *inode = fs->fs_blkdriver;
|
||||
struct inode *inode;
|
||||
|
||||
inode = fs->fs_blkdriver;
|
||||
if (inode && inode->u.i_bops && inode->u.i_bops->read)
|
||||
{
|
||||
ssize_t nsectorsread = inode->u.i_bops->read(inode, buffer,
|
||||
sector, nsectors);
|
||||
ssize_t nsectorsread;
|
||||
|
||||
nsectorsread = inode->u.i_bops->read(inode, buffer,
|
||||
sector, nsectors);
|
||||
if (nsectorsread == nsectors)
|
||||
{
|
||||
ret = OK;
|
||||
|
|
@ -755,13 +768,19 @@ int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
|
|||
int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector,
|
||||
unsigned int nsectors)
|
||||
{
|
||||
int ret = -ENODEV;
|
||||
int ret;
|
||||
|
||||
ret = -ENODEV;
|
||||
if (fs && fs->fs_blkdriver)
|
||||
{
|
||||
struct inode *inode = fs->fs_blkdriver;
|
||||
struct inode *inode;
|
||||
|
||||
inode = fs->fs_blkdriver;
|
||||
if (inode && inode->u.i_bops && inode->u.i_bops->write)
|
||||
{
|
||||
ssize_t nsectorswritten =
|
||||
ssize_t nsectorswritten;
|
||||
|
||||
nsectorswritten =
|
||||
inode->u.i_bops->write(inode, buffer, sector, nsectors);
|
||||
|
||||
if (nsectorswritten == nsectors)
|
||||
|
|
@ -932,7 +951,7 @@ off_t fat_getcluster(struct fat_mountpt_s *fs, uint32_t clusterno)
|
|||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1053,7 +1072,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno,
|
|||
|
||||
fs->fs_buffer[fatindex] = value;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case FSTYPE_FAT16 :
|
||||
{
|
||||
|
|
@ -1071,7 +1090,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno,
|
|||
|
||||
FAT_PUTFAT16(fs->fs_buffer, fatindex, nextcluster & 0xffff);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case FSTYPE_FAT32 :
|
||||
{
|
||||
|
|
@ -1094,7 +1113,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno,
|
|||
FAT_PUTFAT32(fs->fs_buffer, fatindex,
|
||||
val | (nextcluster & 0x0fffffff));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
@ -2037,7 +2056,9 @@ int fat_computefreeclusters(struct fat_mountpt_s *fs)
|
|||
{
|
||||
/* We have to count the number of free clusters */
|
||||
|
||||
uint32_t nfreeclusters = 0;
|
||||
uint32_t nfreeclusters;
|
||||
|
||||
nfreeclusters = 0;
|
||||
if (fs->fs_type == FSTYPE_FAT12)
|
||||
{
|
||||
off_t sector;
|
||||
|
|
@ -2146,7 +2167,9 @@ int fat_nfreeclusters(struct fat_mountpt_s *fs, fsblkcnt_t *pfreeclusters)
|
|||
|
||||
/* Otherwise, we will have to compute the number of free clusters */
|
||||
|
||||
int ret = fat_computefreeclusters(fs);
|
||||
int ret;
|
||||
|
||||
ret = fat_computefreeclusters(fs);
|
||||
if (ret == OK)
|
||||
{
|
||||
*pfreeclusters = fs->fs_fsifreecount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue