diff --git a/fs/binfs/fs_binfs.c b/fs/binfs/fs_binfs.c index 5aa26300b8d..2d273432d5d 100644 --- a/fs/binfs/fs_binfs.c +++ b/fs/binfs/fs_binfs.c @@ -329,7 +329,7 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) finfo("Entry %d: \"%s\"\n", index, name); dir->fd_dir.d_type = DTYPE_FILE; - strncpy(dir->fd_dir.d_name, name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, name, NAME_MAX + 1); /* The application list is terminated by an entry with a NULL name. * Therefore, there is at least one more entry in the list. diff --git a/fs/cromfs/fs_cromfs.c b/fs/cromfs/fs_cromfs.c index a6e53c99dc0..c2b9c9ae634 100644 --- a/fs/cromfs/fs_cromfs.c +++ b/fs/cromfs/fs_cromfs.c @@ -1059,7 +1059,9 @@ static int cromfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) case S_IFIFO: /* FIFO */ case S_IFCHR: /* Character driver */ case S_IFBLK: /* Block driver */ - /* case S_IFSOCK: Socket */ +#if 0 + case S_IFSOCK: /* Socket */ +#endif case S_IFMQ: /* Message queue */ case S_IFSEM: /* Semaphore */ case S_IFSHM: /* Shared memory */ @@ -1183,7 +1185,7 @@ static int cromfs_stat(FAR struct inode *mountpt, FAR const char *relpath, /* Sanity checks */ - DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL && buf != NULL ); + DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL && buf != NULL); memset(buf, 0, sizeof(struct stat)); /* Recover our private data from the inode instance */ diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index 566a31d0397..0a5f4336b9e 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -1765,8 +1765,10 @@ static int fat_truncate(FAR struct file *filep, off_t length) FAR uint8_t *direntry; int ndx; - /* We are shrinking the file. */ - /* Read the directory entry into the fs_buffer. */ + /* We are shrinking the file. + * + * Read the directory entry into the fs_buffer. + */ ret = fat_fscacheread(fs, ff->ff_dirsector); if (ret < 0) @@ -2255,7 +2257,7 @@ static int fat_statfs(FAR struct inode *mountpt, FAR struct statfs *buf) #ifdef CONFIG_FAT_LFN buf->f_namelen = LDIR_MAXFNAME; /* Maximum length of filenames */ #else - buf->f_namelen = (8+1+3); /* Maximum length of filenames */ + buf->f_namelen = (8 + 1 + 3); /* Maximum length of filenames */ #endif } @@ -2295,8 +2297,10 @@ static int fat_unlink(FAR struct inode *mountpt, FAR const char *relpath) * open reference to the file is closed. */ - /* Remove the file */ - /* TODO: Need to defer deleting cluster chain if the file is open. */ + /* Remove the file + * + * TODO: Need to defer deleting cluster chain if the file is open. + */ ret = fat_remove(fs, relpath, false); } @@ -2463,7 +2467,7 @@ static int fat_mkdir(FAR struct inode *mountpt, FAR const char *relpath, /* So far, the two entries are nearly the same */ memcpy(direntry2, direntry, DIR_SIZE); - direntry2[DIR_NAME+1] = '.'; + direntry2[DIR_NAME + 1] = '.'; /* Now add the cluster information to both directory entries */ @@ -2554,8 +2558,10 @@ int fat_rmdir(FAR struct inode *mountpt, FAR const char *relpath) * open reference to the directory is closed. */ - /* Remove the directory */ - /* TODO: Need to defer deleting cluster chain if the file is open. */ + /* Remove the directory. + * + * TODO: Need to defer deleting cluster chain if the file is open. + */ ret = fat_remove(fs, relpath, true); } @@ -2578,7 +2584,7 @@ int fat_rename(FAR struct inode *mountpt, FAR const char *oldrelpath, FAR struct fat_dirinfo_s dirinfo; FAR struct fat_dirseq_s dirseq; uint8_t *direntry; - uint8_t dirstate[DIR_SIZE-DIR_ATTRIBUTES]; + uint8_t dirstate[DIR_SIZE - DIR_ATTRIBUTES]; int ret; /* Sanity checks */ @@ -2631,7 +2637,7 @@ int fat_rename(FAR struct inode *mountpt, FAR const char *oldrelpath, /* Save the non-name-related portion of the directory entry intact */ direntry = &fs->fs_buffer[dirinfo.fd_seq.ds_offset]; - memcpy(dirstate, &direntry[DIR_ATTRIBUTES], DIR_SIZE-DIR_ATTRIBUTES); + memcpy(dirstate, &direntry[DIR_ATTRIBUTES], DIR_SIZE - DIR_ATTRIBUTES); /* Now find the directory where we should create the newpath object */ @@ -2683,7 +2689,7 @@ int fat_rename(FAR struct inode *mountpt, FAR const char *oldrelpath, /* Copy the unchanged information into the new short file name entry. */ direntry = &fs->fs_buffer[dirinfo.fd_seq.ds_offset]; - memcpy(&direntry[DIR_ATTRIBUTES], dirstate, DIR_SIZE-DIR_ATTRIBUTES); + memcpy(&direntry[DIR_ATTRIBUTES], dirstate, DIR_SIZE - DIR_ATTRIBUTES); fs->fs_dirty = true; /* Remove the old entry, flushing the new directory entry to disk. If diff --git a/fs/fat/fs_fat32dirent.c b/fs/fat/fs_fat32dirent.c index 2be3ce261f0..fa6496ad659 100644 --- a/fs/fat/fs_fat32dirent.c +++ b/fs/fat/fs_fat32dirent.c @@ -909,8 +909,8 @@ static inline int fat_uniquealias(struct fat_mountpt_s *fs, /* Back up the tilde and break out of the inner loop */ tilde--; - dirinfo->fd_name[tilde] = '~'; - dirinfo->fd_name[tilde+1] = '1'; + dirinfo->fd_name[tilde] = '~'; + dirinfo->fd_name[tilde + 1] = '1'; break; } @@ -1219,7 +1219,7 @@ static inline int fat_findlfnentry(struct fat_mountpt_s *fs, */ namelen = strlen((FAR char *)dirinfo->fd_lfname); - DEBUGASSERT(namelen <= LDIR_MAXFNAME+1); + DEBUGASSERT(namelen <= LDIR_MAXFNAME + 1); /* How many LFN directory entries are we expecting? */ @@ -1520,7 +1520,7 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs, */ namelen = strlen((char *)dirinfo->fd_lfname); - DEBUGASSERT(namelen <= LDIR_MAXFNAME+1); + DEBUGASSERT(namelen <= LDIR_MAXFNAME + 1); /* How many LFN directory entries are we expecting? */ @@ -1859,7 +1859,7 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di * spaces. */ - for (; nsrc > 0 && lfname[nsrc-1] == ' '; nsrc--); + for (; nsrc > 0 && lfname[nsrc - 1] == ' '; nsrc--); /* Further reduce the length so that it fits in the destination * buffer. @@ -1875,14 +1875,14 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di * terminator will fit). */ - dir->fd_dir.d_name[offset+nsrc] = '\0'; + dir->fd_dir.d_name[offset + nsrc] = '\0'; } /* Then transfer the characters */ - for (i = 0; i < nsrc && offset+i < NAME_MAX; i++) + for (i = 0; i < nsrc && offset + i < NAME_MAX; i++) { - dir->fd_dir.d_name[offset+i] = lfname[i]; + dir->fd_dir.d_name[offset + i] = lfname[i]; } } @@ -2061,7 +2061,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, */ namelen = strlen((FAR char *)dirinfo->fd_lfname); - DEBUGASSERT(namelen <= LDIR_MAXFNAME+1); + DEBUGASSERT(namelen <= LDIR_MAXFNAME + 1); /* How many LFN directory entries do we need to write? */ @@ -2159,7 +2159,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, { nbytes = MIN(6, remainder); fat_putlfnchunk(LDIR_PTRWCHAR6_11(direntry), - &dirinfo->fd_lfname[offset+5], nbytes); + &dirinfo->fd_lfname[offset + 5], nbytes); remainder -= nbytes; } @@ -2167,7 +2167,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, { nbytes = MIN(2, remainder); fat_putlfnchunk(LDIR_PTRWCHAR12_13(direntry), - &dirinfo->fd_lfname[offset+11], nbytes); + &dirinfo->fd_lfname[offset + 11], nbytes); remainder -= nbytes; } @@ -2182,9 +2182,9 @@ static int fat_putlfname(struct fat_mountpt_s *fs, fat_putlfnchunk(LDIR_PTRWCHAR1_5(direntry), &dirinfo->fd_lfname[offset], 5); fat_putlfnchunk(LDIR_PTRWCHAR6_11(direntry), - &dirinfo->fd_lfname[offset+5], 6); + &dirinfo->fd_lfname[offset + 5], 6); fat_putlfnchunk(LDIR_PTRWCHAR12_13(direntry), - &dirinfo->fd_lfname[offset+11], 2); + &dirinfo->fd_lfname[offset + 11], 2); } /* Write the remaining directory entries */ @@ -2727,7 +2727,7 @@ int fat_dirname2path(struct fat_mountpt_s *fs, struct fs_dirent_s *dir) { /* No.. Get the name from a short file name directory entries */ - return fat_getsfname(direntry, dir->fd_dir.d_name, NAME_MAX+1); + return fat_getsfname(direntry, dir->fd_dir.d_name, NAME_MAX + 1); } } diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c index 91e67029e57..6d305797a39 100644 --- a/fs/fat/fs_fat32util.c +++ b/fs/fat/fs_fat32util.c @@ -438,13 +438,13 @@ uint32_t fat_systime2fattime(void) uint16_t fattime; uint16_t fatdate; - fattime = (tm.tm_sec >> 1) & 0x001f; /* Bits 0-4: 2 second count (0-29) */ - fattime |= (tm.tm_min << 5) & 0x07e0; /* Bits 5-10: minutes (0-59) */ - fattime |= (tm.tm_hour << 11) & 0xf800; /* Bits 11-15: hours (0-23) */ + fattime = (tm.tm_sec >> 1) & 0x001f; /* Bits 0-4: 2 second count (0-29) */ + fattime |= (tm.tm_min << 5) & 0x07e0; /* Bits 5-10: minutes (0-59) */ + fattime |= (tm.tm_hour << 11) & 0xf800; /* Bits 11-15: hours (0-23) */ - fatdate = tm.tm_mday & 0x001f; /* Bits 0-4: Day of month (1-31) */ - fatdate |= ((tm.tm_mon+1) << 5) & 0x01e0; /* Bits 5-8: Month of year (1-12) */ - fatdate |= ((tm.tm_year-80) << 9) & 0xfe00; /* Bits 9-15: Year from 1980 */ + fatdate = tm.tm_mday & 0x001f; /* Bits 0-4: Day of month (1-31) */ + fatdate |= ((tm.tm_mon + 1) << 5) & 0x01e0; /* Bits 5-8: Month of year (1-12) */ + fatdate |= ((tm.tm_year - 80) << 9) & 0xfe00; /* Bits 9-15: Year from 1980 */ return (uint32_t)fatdate << 16 | (uint32_t)fattime; } @@ -490,7 +490,7 @@ time_t fat_fattime2systime(uint16_t fattime, uint16_t fatdate) tm.tm_mday = (fatdate & 0x001f); /* Bits 0-4: Day of month (1-31) */ tmp = ((fatdate & 0x01e0) >> 5); /* Bits 5-8: Month of year (1-12) */ - tm.tm_mon = tmp > 0 ? tmp-1 : 0; + tm.tm_mon = tmp > 0 ? tmp - 1 : 0; tm.tm_year = ((fatdate & 0xfe00) >> 9) + 80; /* Bits 9-15: Year from 1980 */ /* Then convert the broken out time into seconds since the epoch */ @@ -1395,7 +1395,7 @@ int fat_nextdirentry(struct fat_mountpt_s *fs, struct fs_fatdir_s *dir) * has been examined. */ - if ((sector & (fs->fs_fatsecperclus-1)) == 0) + if ((sector & (fs->fs_fatsecperclus - 1)) == 0) { /* Get next cluster */ @@ -1542,7 +1542,7 @@ int fat_dirshrink(struct fat_mountpt_s *fs, FAR uint8_t *direntry, return cluster; } - clustersize = fs->fs_fatsecperclus * fs->fs_hwsectorsize;; + clustersize = fs->fs_fatsecperclus * fs->fs_hwsectorsize; remaining = length; while (cluster >= 2 && cluster < fs->fs_nclusters) diff --git a/fs/hostfs/hostfs.c b/fs/hostfs/hostfs.c index a385e573e8d..09093ac7cdd 100644 --- a/fs/hostfs/hostfs.c +++ b/fs/hostfs/hostfs.c @@ -258,7 +258,7 @@ static void hostfs_mkpath(FAR struct hostfs_mountpt_s *fs, if (depth >= 0) { - strncat(path, &relpath[first], pathlen-strlen(path)-1); + strncat(path, &relpath[first], pathlen - strlen(path) - 1); } } @@ -1000,12 +1000,12 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data, { /* Remove trailing '/' */ - fs->fs_root[len-1] = '\0'; + fs->fs_root[len - 1] = '\0'; } /* Append a '/' to the name now */ - if (fs->fs_root[len-1] != '/') + if (fs->fs_root[len - 1] != '/') { strcat(fs->fs_root, "/"); } diff --git a/fs/littlefs/lfs.c b/fs/littlefs/lfs.c index d4e4bfe023a..bee4a6d7ea2 100644 --- a/fs/littlefs/lfs.c +++ b/fs/littlefs/lfs.c @@ -814,17 +814,17 @@ static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir, break; - relocate: - /* commit was corrupted */ +relocate: + /* Commit was corrupted */ LFS_DEBUG("Bad block at %" PRIu32, dir->pair[0]); - /* drop caches and prepare to relocate block */ + /* Drop caches and prepare to relocate block */ relocated = true; lfs_cache_drop(lfs, &lfs->pcache); - /* can't relocate superblock, filesystem is now frozen */ + /* Can't relocate superblock, filesystem is now frozen */ if (lfs_paircmp(oldpair, (const lfs_block_t[2]){ 0, 1 }) == 0) { diff --git a/fs/mount/fs_automount.c b/fs/mount/fs_automount.c index 590c6e00146..1ad1a6c75f0 100644 --- a/fs/mount/fs_automount.c +++ b/fs/mount/fs_automount.c @@ -79,6 +79,7 @@ /**************************************************************************** * Private Types ****************************************************************************/ + /* This structure describes the state of the automounter */ struct automounter_state_s diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index 68c05bbdabd..88641aa4858 100644 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -63,7 +63,9 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ + /* In the canonical case, a file system is bound to a block driver. However, * some less typical cases a block driver is not required. Examples are * pseudo file systems (like BINFS or PROCFS) and MTD file systems (like NXFFS). diff --git a/fs/mount/fs_procfs_mount.c b/fs/mount/fs_procfs_mount.c index 70a27059eec..df119e7ee87 100644 --- a/fs/mount/fs_procfs_mount.c +++ b/fs/mount/fs_procfs_mount.c @@ -307,7 +307,10 @@ static int usage_entry(FAR const char *mountpoint, FAR struct statfs *statbuf, char sizelabel; char freelabel; char usedlabel; - static const char labels[5] = { 'B', 'K', 'M', 'G', 'T' }; + static const char labels[5] = + { + 'B', 'K', 'M', 'G', 'T' + }; DEBUGASSERT(mountpoint != NULL && statbuf != NULL && info != NULL); diff --git a/fs/mount/fs_umount2.c b/fs/mount/fs_umount2.c index 598cb7b1967..455afc01681 100644 --- a/fs/mount/fs_umount2.c +++ b/fs/mount/fs_umount2.c @@ -147,7 +147,6 @@ int umount2(FAR const char *target, unsigned int flags) * pseudo-file inode. */ - mountpt_inode->i_flags &= ~FSNODEFLAG_TYPE_MASK; mountpt_inode->i_private = NULL; mountpt_inode->u.i_mops = NULL; diff --git a/fs/mqueue/mq_close.c b/fs/mqueue/mq_close.c index 43b14ee5cf8..7647ccda7c9 100644 --- a/fs/mqueue/mq_close.c +++ b/fs/mqueue/mq_close.c @@ -166,7 +166,6 @@ int mq_close(mqd_t mqdes) return ret; } - /**************************************************************************** * Name: mq_inode_release * diff --git a/fs/nfs/nfs_util.c b/fs/nfs/nfs_util.c index c012ef39b51..780ff9d7a1e 100644 --- a/fs/nfs/nfs_util.c +++ b/fs/nfs/nfs_util.c @@ -86,7 +86,7 @@ static inline int nfs_pathsegment(FAR const char **path, FAR char *buffer, if (ch == '\0' || ch == '/') { - /* This logic just suppors "//" sequences in the path name */ + /* This logic just supports "//" sequences in the path name */ if (ch == '\0' || nbytes > 0) { @@ -390,7 +390,7 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath, FAR struct nfs_fattr *dir_attributes) { FAR const char *path = relpath; - char buffer[NAME_MAX+1]; + char buffer[NAME_MAX + 1]; char terminator; uint32_t tmp; int error; diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c index 85840c981f2..6dcbb0fbd3d 100644 --- a/fs/nfs/nfs_vfsops.c +++ b/fs/nfs/nfs_vfsops.c @@ -535,8 +535,10 @@ static int nfs_fileopen(FAR struct nfsmount *nmp, FAR struct nfsnode *np, return EEXIST; } - /* Initialize the file private data */ - /* Copy the file handle */ + /* Initialize the file private data. + * + * Copy the file handle. + */ np->n_fhsize = (uint8_t)fhandle.length; memcpy(&np->n_fhandle, &fhandle.handle, fhandle.length); @@ -2119,7 +2121,9 @@ int nfs_fsinfo(FAR struct nfsmount *nmp) /* Save the root file system attributes */ -//memcpy(&nmp->nm_fattr. &fsp.obj_attributes, sizeof(struct nfs_fattr)); +#if 0 + memcpy(&nmp->nm_fattr. &fsp.obj_attributes, sizeof(struct nfs_fattr)); +#endif pref = fxdr_unsigned(uint32_t, fsp.fsinfo.fs_wtpref); if (pref < nmp->nm_wsize) @@ -2560,8 +2564,8 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath, struct nfsmount *nmp; struct file_handle from_handle; struct file_handle to_handle; - char from_name[NAME_MAX+1]; - char to_name[NAME_MAX+1]; + char from_name[NAME_MAX + 1]; + char to_name[NAME_MAX + 1]; struct nfs_fattr fattr; FAR uint32_t *ptr; int namelen; diff --git a/fs/nxffs/nxffs_blockstats.c b/fs/nxffs/nxffs_blockstats.c index d1c3b8fb8de..4b26bbdaa44 100644 --- a/fs/nxffs/nxffs_blockstats.c +++ b/fs/nxffs/nxffs_blockstats.c @@ -115,8 +115,10 @@ int nxffs_blockstats(FAR struct nxffs_volume_s *volume, stats->nblocks++; - /* Collect statistics */ - /* Check if this is a block that should be recognized by NXFFS */ + /* Collect statistics. + * + * Check if this is a block that should be recognized by NXFFS. + */ if (memcmp(blkhdr->magic, g_blockmagic, NXFFS_MAGICSIZE) != 0) { @@ -189,8 +191,10 @@ int nxffs_blockstats(FAR struct nxffs_volume_s *volume, FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s *)volume->pack; - /* Collect statistics */ - /* Check if this is a block that should be recognized by NXFFS */ + /* Collect statistics. + * + * Check if this is a block that should be recognized by NXFFS. + */ if (memcmp(blkhdr->magic, g_blockmagic, NXFFS_MAGICSIZE) != 0) { diff --git a/fs/nxffs/nxffs_dirent.c b/fs/nxffs/nxffs_dirent.c index 298238232b3..4c21b1eada0 100644 --- a/fs/nxffs/nxffs_dirent.c +++ b/fs/nxffs/nxffs_dirent.c @@ -150,7 +150,7 @@ int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir) finfo("Offset %d: \"%s\"\n", entry.hoffset, entry.name); dir->fd_dir.d_type = DTYPE_FILE; - strncpy(dir->fd_dir.d_name, entry.name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, entry.name, NAME_MAX + 1); /* Discard this entry and set the next offset. */ diff --git a/fs/nxffs/nxffs_dump.c b/fs/nxffs/nxffs_dump.c index a76c503e27a..fb290479f39 100644 --- a/fs/nxffs/nxffs_dump.c +++ b/fs/nxffs/nxffs_dump.c @@ -100,7 +100,9 @@ static inline ssize_t nxffs_analyzeinode(FAR struct nxffs_blkinfo_s *blkinfo, uint8_t state; uint32_t noffs; uint32_t doffs; -//uint32_t utc; +#if 0 + uint32_t utc; +#endif uint32_t ecrc; uint32_t datlen; uint32_t crc; @@ -120,7 +122,9 @@ static inline ssize_t nxffs_analyzeinode(FAR struct nxffs_blkinfo_s *blkinfo, memcpy(&inode, &blkinfo->buffer[offset], SIZEOF_NXFFS_INODE_HDR); noffs = nxffs_rdle32(inode.noffs); doffs = nxffs_rdle32(inode.doffs); -//utc = nxffs_rdle32(inode.utc); +#if 0 + utc = nxffs_rdle32(inode.utc); +#endif ecrc = nxffs_rdle32(inode.crc); datlen = nxffs_rdle32(inode.datlen); @@ -135,7 +139,6 @@ static inline ssize_t nxffs_analyzeinode(FAR struct nxffs_blkinfo_s *blkinfo, return ERROR; } - /* Can we verify the inode? We need to have the inode name in the same * block to do that (or get access to the next block) */ diff --git a/fs/nxffs/nxffs_open.c b/fs/nxffs/nxffs_open.c index 8276a399a63..9353dc290d0 100644 --- a/fs/nxffs/nxffs_open.c +++ b/fs/nxffs/nxffs_open.c @@ -1180,7 +1180,6 @@ int nxffs_close(FAR struct file *filep) ofile->crefs--; } - filep->f_priv = NULL; nxsem_post(&volume->exclsem); diff --git a/fs/nxffs/nxffs_pack.c b/fs/nxffs/nxffs_pack.c index 0c6819a465f..efd7184019a 100644 --- a/fs/nxffs/nxffs_pack.c +++ b/fs/nxffs/nxffs_pack.c @@ -58,6 +58,7 @@ /**************************************************************************** * Public Types ****************************************************************************/ + /* This structure supports access to one inode data stream */ struct nxffs_packstream_s diff --git a/fs/nxffs/nxffs_truncate.c b/fs/nxffs/nxffs_truncate.c index e4b1cbeaae4..cb5130101e0 100644 --- a/fs/nxffs/nxffs_truncate.c +++ b/fs/nxffs/nxffs_truncate.c @@ -117,8 +117,10 @@ int nxffs_truncate(FAR struct file *filep, off_t length) } else if (oldsize > length) { - /* We are shrinking the file */ - /* REVISIT: Logic to shrink the file has not yet been implemented */ + /* We are shrinking the file. + * + * REVISIT: Logic to shrink the file has not yet been implemented. + */ ret = -ENOSYS; } diff --git a/fs/nxffs/nxffs_util.c b/fs/nxffs/nxffs_util.c index 7893798ade1..11a55f47855 100644 --- a/fs/nxffs/nxffs_util.c +++ b/fs/nxffs/nxffs_util.c @@ -130,7 +130,7 @@ void nxffs_wrle32(uint8_t *dest, uint32_t val) /* Little endian means LS halfword first in byte stream */ nxffs_wrle16(dest, (uint16_t)(val & 0xffff)); - nxffs_wrle16(dest+2, (uint16_t)(val >> 16)); + nxffs_wrle16(dest + 2, (uint16_t)(val >> 16)); } /**************************************************************************** diff --git a/fs/partition/fs_partition.c b/fs/partition/fs_partition.c index d5551e1bb4d..4e065e6d384 100644 --- a/fs/partition/fs_partition.c +++ b/fs/partition/fs_partition.c @@ -104,7 +104,8 @@ static int parse_partition(FAR struct partition_state_s *state, partition_handler_t handler, FAR void *arg) { - int i, ret = 0; + int i; + int ret = 0; for (i = 0; g_parser[i] != NULL; i++) { diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 9077bb51e87..121e61c2991 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -109,6 +109,7 @@ extern const struct procfs_operations ccm_procfsoperations; /**************************************************************************** * Private Types ****************************************************************************/ + /* Table of all known / pre-registered procfs handlers / participants. */ #ifdef CONFIG_FS_PROCFS_REGISTER @@ -199,6 +200,7 @@ static const uint8_t g_procfs_entrycount = sizeof(g_procfs_entries) / /**************************************************************************** * Private Function Prototypes ****************************************************************************/ + /* Helpers */ static void procfs_enum(FAR struct tcb_s *tcb, FAR void *arg); @@ -358,7 +360,8 @@ static void procfs_enum(FAR struct tcb_s *tcb, FAR void *arg) static int procfs_open(FAR struct file *filep, FAR const char *relpath, int oflags, mode_t mode) { - int x, ret = -ENOENT; + int x; + int ret = -ENOENT; finfo("Open '%s'\n", relpath); @@ -845,7 +848,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) /* Save the filename=pid and file type=directory */ dir->fd_dir.d_type = DTYPE_DIRECTORY; - snprintf(dir->fd_dir.d_name, NAME_MAX+1, "%d", (int)pid); + snprintf(dir->fd_dir.d_name, NAME_MAX + 1, "%d", (int)pid); /* Set up the next directory entry offset. NOTE that we could use the * standard f_pos instead of our own private index. @@ -1030,8 +1033,9 @@ static int procfs_stat(struct inode *mountpt, const char *relpath, memset(buf, 0, sizeof(struct stat)); if (!relpath || relpath[0] == '\0') { - /* The path refers to the top level directory */ - /* It's a read-only directory */ + /* The path refers to the top level directory. + * It's a read-only directory. + */ buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; ret = OK; diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index abcf52aac16..6b75715911b 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -90,7 +90,7 @@ struct progmem_info_s int ordblks; /* This is the number of free chunks */ int mxordblk; /* Size of the largest free chunk */ int uordblks; /* Total size of memory for allocated chunks */ - int fordblks; /* Total size of memory for free chunks.*/ + int fordblks; /* Total size of memory for free chunks. */ }; #endif diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 642466f52f8..76dc0d4145b 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -76,6 +76,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* See include/nuttx/sched.h: */ #undef HAVE_GROUPID @@ -1696,8 +1697,11 @@ static int proc_readdir(struct fs_dirent_s *dir) return -ENOENT; } - /* The TCB is still valid (or at least was when we entered this function) */ - /* Handle the directory listing by the node type */ + /* The TCB is still valid (or at least was when we entered this + * function) + * + * Handle the directory listing by the node type. + */ switch (procdir->node->node) { @@ -1718,7 +1722,7 @@ static int proc_readdir(struct fs_dirent_s *dir) /* Save the filename and file type */ dir->fd_dir.d_type = node->dtype; - strncpy(dir->fd_dir.d_name, node->name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, node->name, NAME_MAX + 1); /* Set up the next directory entry offset. NOTE that we could use the * standard f_pos instead of our own private index. diff --git a/fs/procfs/fs_skeleton.c b/fs/procfs/fs_skeleton.c index 51c6f785e11..8534cd3f0b2 100644 --- a/fs/procfs/fs_skeleton.c +++ b/fs/procfs/fs_skeleton.c @@ -101,6 +101,7 @@ struct skel_level1_s /**************************************************************************** * Private Function Prototypes ****************************************************************************/ + /* File system methods */ static int skel_open(FAR struct file *filep, FAR const char *relpath, @@ -108,7 +109,9 @@ static int skel_open(FAR struct file *filep, FAR const char *relpath, static int skel_close(FAR struct file *filep); static ssize_t skel_read(FAR struct file *filep, FAR char *buffer, size_t buflen); + /* TODO: Should not support skel_write if read-only */ + static ssize_t skel_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int skel_dup(FAR const struct file *oldp, @@ -140,7 +143,9 @@ const struct procfs_operations skel_procfsoperations = skel_open, /* open */ skel_close, /* close */ skel_read, /* read */ + /* TODO: Decide if this procfs entry supports write access */ + #if 0 /* NULL if the procfs entry does not support write access. */ NULL, /* write */ #else @@ -270,6 +275,7 @@ static ssize_t skel_read(FAR struct file *filep, FAR char *buffer, ****************************************************************************/ /* TODO: Should not support skel_write if read-only */ + static ssize_t skel_write(FAR struct file *filep, FAR const char *buffer, size_t buflen) { @@ -502,10 +508,11 @@ static int skel_stat(FAR const char *relpath, FAR struct stat *buf) buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; /* TODO: Set S_IFREG if the relpath refers to a file. - /* TODO: If the skel_write() method is supported, then stat must also + * TODO: If the skel_write() method is supported, then stat must also * report S_IWOTH | S_IWGRP | S_IWUSR for files (but not for * directories) as well. - /* TODO: Other 'struct buf' settings may be appropriate (optional) */ + * TODO: Other 'struct buf' settings may be appropriate (optional) + */ ret = OK; diff --git a/fs/romfs/fs_romfsutil.c b/fs/romfs/fs_romfsutil.c index 2f8be006d42..86598b6c480 100644 --- a/fs/romfs/fs_romfsutil.c +++ b/fs/romfs/fs_romfsutil.c @@ -94,7 +94,7 @@ static inline int romfs_checkentry(struct romfs_mountpt_s *rm, int entrylen, struct romfs_dirinfo_s *dirinfo) { - char name[NAME_MAX+1]; + char name[NAME_MAX + 1]; uint32_t linkoffset; uint32_t next; uint32_t info; diff --git a/fs/smartfs/smartfs_procfs.c b/fs/smartfs/smartfs_procfs.c index 915ebfd559c..3f1c28c2739 100644 --- a/fs/smartfs/smartfs_procfs.c +++ b/fs/smartfs/smartfs_procfs.c @@ -115,6 +115,7 @@ struct smartfs_procfs_entry_s /**************************************************************************** * Private Function Prototypes ****************************************************************************/ + /* File system methods */ static int smartfs_open(FAR struct file *filep, FAR const char *relpath, @@ -187,6 +188,7 @@ const struct procfs_operations smartfs_procfsoperations = smartfs_read, /* read */ /* No write supported */ + smartfs_write, /* write */ smartfs_dup, /* dup */ @@ -646,7 +648,8 @@ static int smartfs_readdir(struct fs_dirent_s *dir) } dir->fd_dir.d_type = DTYPE_DIRECTORY; - strncpy(dir->fd_dir.d_name, level1->mount->fs_blkdriver->i_name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, level1->mount->fs_blkdriver->i_name, + NAME_MAX + 1); /* Advance to next entry */ @@ -658,14 +661,16 @@ static int smartfs_readdir(struct fs_dirent_s *dir) /* Listing the contents of a specific mount */ dir->fd_dir.d_type = g_direntry[level1->base.index].type; - strncpy(dir->fd_dir.d_name, g_direntry[level1->base.index++].name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, g_direntry[level1->base.index++].name, + NAME_MAX + 1); } else if (level1->base.level == 3) { /* Listing the contents of a specific entry */ dir->fd_dir.d_type = g_direntry[level1->base.index].type; - strncpy(dir->fd_dir.d_name, g_direntry[level1->direntry].name, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, g_direntry[level1->direntry].name, + NAME_MAX + 1); level1->base.index++; } @@ -798,7 +803,6 @@ static size_t smartfs_status_read(FAR struct file *filep, FAR char *buffer, priv = (FAR struct smartfs_file_s *) filep->f_priv; - /* Initialize the read length to zero and test if we are at the * end of the file (i.e. already read the data. */ @@ -878,7 +882,6 @@ static size_t smartfs_mem_read(FAR struct file *filep, FAR char *buffer, priv = (FAR struct smartfs_file_s *) filep->f_priv; - /* Initialize the read length to zero and test if we are at the * end of the file (i.e. already read the data. */ @@ -905,7 +908,7 @@ static size_t smartfs_mem_read(FAR struct file *filep, FAR char *buffer, if (procfs_data.allocs[x].ptr != NULL) { - len += snprintf(&buffer[len], buflen-len, " %s: %d\n", + len += snprintf(&buffer[len], buflen - len, " %s: %d\n", procfs_data.allocs[x].name, procfs_data.allocs[x].size); total += procfs_data.allocs[x].size; } @@ -913,7 +916,7 @@ static size_t smartfs_mem_read(FAR struct file *filep, FAR char *buffer, /* Add the total allocation amount to the buffer */ - len += snprintf(&buffer[len], buflen-len, "\nTotal: %d\n", total); + len += snprintf(&buffer[len], buflen - len, "\nTotal: %d\n", total); } /* Indicate we have done the read */ @@ -988,7 +991,7 @@ static size_t smartfs_erasemap_read(FAR struct file *filep, FAR char *buffer, if (copylen >= priv->offset) { - buffer[len++] = procfs_data.erasecounts[y*cols+x] + 'A'; + buffer[len++] = procfs_data.erasecounts[y * cols + x] + 'A'; priv->offset++; if (len >= buflen) diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c index 8103df616b8..ba5c73120aa 100644 --- a/fs/smartfs/smartfs_smart.c +++ b/fs/smartfs/smartfs_smart.c @@ -238,7 +238,7 @@ static int smartfs_open(FAR struct file *filep, const char *relpath, if (ret == OK) { - /* The name exists -- but is is a file or a directory ? */ + /* The name exists -- but is is a file or a directory? */ if (sf->entry.flags & SMARTFS_DIRENT_TYPE_DIR) { @@ -261,7 +261,8 @@ static int smartfs_open(FAR struct file *filep, const char *relpath, /* TODO: Test open mode based on the file mode */ /* The file exists. Check if we are opening it for O_CREAT or - * O_TRUNC mode and delete the sector chain if we are. */ + * O_TRUNC mode and delete the sector chain if we are. + */ if ((oflags & (O_CREAT | O_TRUNC)) != 0) { @@ -429,12 +430,14 @@ static int smartfs_close(FAR struct file *filep) smartfs_semtake(fs); /* Check if we are the last one with a reference to the file and - * only close if we are. */ + * only close if we are. + */ if (sf->crefs > 1) { /* The file is opened more than once. Just decrement the - * reference count and return. */ + * reference count and return. + */ sf->crefs--; goto okout; @@ -675,7 +678,8 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer, } /* First test if we are overwriting an existing location or writing to - * a new one. */ + * a new one. + */ header = (struct smartfs_chain_header_s *) fs->fs_rwbuffer; byteswritten = 0; @@ -1402,7 +1406,8 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data, } /* If the global semaphore hasn't been initialized, then - * initialized it now. */ + * initialized it now. + */ fs->fs_sem = &g_sem; if (!g_seminitialized) @@ -1648,7 +1653,8 @@ static int smartfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode else if (ret == -ENOENT) { /* It doesn't exist ... we can create it, but only if we have - * the right permissions and if the parentdirsector is valid. */ + * the right permissions and if the parentdirsector is valid. + */ if (parentdirsector == 0xFFFF) { diff --git a/fs/smartfs/smartfs_utils.c b/fs/smartfs/smartfs_utils.c index 100ba8cda9e..20436d4478a 100644 --- a/fs/smartfs/smartfs_utils.c +++ b/fs/smartfs/smartfs_utils.c @@ -184,7 +184,7 @@ void smartfs_wrle32(uint8_t *dest, uint32_t val) /* Little endian means LS halfword first in byte stream */ smartfs_wrle16(dest, (uint16_t)(val & 0xffff)); - smartfs_wrle16(dest+2, (uint16_t)(val >> 16)); + smartfs_wrle16(dest + 2, (uint16_t)(val >> 16)); } /**************************************************************************** @@ -669,7 +669,8 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs, direntry->dfirst = dirstack[depth]; if (direntry->name == NULL) { - direntry->name = (char *) kmm_malloc(fs->fs_llformat.namesize+1); + direntry->name = (FAR char *) + kmm_malloc(fs->fs_llformat.namesize + 1); } memset(direntry->name, 0, fs->fs_llformat.namesize + 1); @@ -1073,10 +1074,10 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs, direntry->datlen = 0; if (direntry->name == NULL) { - direntry->name = (FAR char *) kmm_malloc(fs->fs_llformat.namesize+1); + direntry->name = (FAR char *)kmm_malloc(fs->fs_llformat.namesize + 1); } - memset(direntry->name, 0, fs->fs_llformat.namesize+1); + memset(direntry->name, 0, fs->fs_llformat.namesize + 1); strncpy(direntry->name, filename, fs->fs_llformat.namesize); ret = OK; @@ -1218,6 +1219,7 @@ int smartfs_deleteentry(struct smartfs_mountpt_s *fs, #endif { /* Count this entry */ + count++; } @@ -1370,6 +1372,7 @@ int smartfs_countdirentries(struct smartfs_mountpt_s *fs, #endif { /* Count this entry */ + count++; } @@ -1439,7 +1442,8 @@ int smartfs_sync_internal(FAR struct smartfs_mountpt_s *fs, #else /* CONFIG_SMARTFS_USE_SECTOR_BUFFER */ /* Test if we have written bytes to the current sector that - * need to be recorded in the chain header's used bytes field. */ + * need to be recorded in the chain header's used bytes field. + */ if (sf->byteswritten > 0) { @@ -1571,8 +1575,9 @@ off_t smartfs_seek_internal(FAR struct smartfs_mountpt_s *fs, { /* Seeking within the current sector. Just update the offset */ - sf->curroffset = sizeof(struct smartfs_chain_header_s) + newpos-sectorstartpos; - sf->filepos = newpos; + sf->curroffset = sizeof(struct smartfs_chain_header_s) + + newpos - sectorstartpos; + sf->filepos = newpos; return newpos; } @@ -1931,7 +1936,7 @@ int smartfs_extendfile(FAR struct smartfs_mountpt_s *fs, readwrite.count = fs->fs_llformat.availbytes - sf->curroffset; if (readwrite.count > remaining) { - /* Limit the write to the size for our smaller working buffer*/ + /* Limit the write to the size for our smaller working buffer */ readwrite.count = SMARTFS_TRUNCBUFFER_SIZE; } diff --git a/fs/spiffs/src/spiffs_cache.c b/fs/spiffs/src/spiffs_cache.c index bf5a801ec1a..8484c8ac10d 100644 --- a/fs/spiffs/src/spiffs_cache.c +++ b/fs/spiffs/src/spiffs_cache.c @@ -270,6 +270,7 @@ static FAR struct spiffs_cache_page_s * FAR struct spiffs_cache_page_s *cp; /* We found one */ + cp = spiffs_get_cache_page_hdr(fs, cache, i); cache->cpage_use_map |= (1 << i); cp->last_access = cache->last_access; @@ -311,7 +312,7 @@ void spiffs_cache_initialize(FAR struct spiffs_s *fs) int cache_entries; sz = fs->cache_size; - cache_entries = (sz - sizeof(struct spiffs_cache_s )) / + cache_entries = (sz - sizeof(struct spiffs_cache_s)) / (SPIFFS_CACHE_PAGE_SIZE(fs)); if (fs->cache == 0) @@ -330,14 +331,14 @@ void spiffs_cache_initialize(FAR struct spiffs_s *fs) cache_mask |= 1; } - memset(&cache, 0, sizeof(struct spiffs_cache_s )); + memset(&cache, 0, sizeof(struct spiffs_cache_s)); cache.cpage_count = cache_entries; - cache.cpages = (FAR uint8_t*) - ((FAR uint8_t *)fs->cache + sizeof(struct spiffs_cache_s )); + cache.cpages = (FAR uint8_t *) + ((FAR uint8_t *)fs->cache + sizeof(struct spiffs_cache_s)); cache.cpage_use_map = 0xffffffff; cache.cpage_use_mask = cache_mask; - memcpy(fs->cache, &cache, sizeof(struct spiffs_cache_s )); + memcpy(fs->cache, &cache, sizeof(struct spiffs_cache_s)); cp = spiffs_get_cache(fs); memset(cp->cpages, 0, cp->cpage_count * SPIFFS_CACHE_PAGE_SIZE(fs)); diff --git a/fs/spiffs/src/spiffs_check.c b/fs/spiffs/src/spiffs_check.c index 3a9056cefb4..41dce3d1454 100644 --- a/fs/spiffs/src/spiffs_check.c +++ b/fs/spiffs/src/spiffs_check.c @@ -320,7 +320,7 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs, } ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_UPDT, 0, - SPIFFS_BLOCK_TO_PADDR(fs, SPIFFS_BLOCK_FOR_PAGE(fs,free_pgndx)) + + SPIFFS_BLOCK_TO_PADDR(fs, SPIFFS_BLOCK_FOR_PAGE(fs, free_pgndx)) + SPIFFS_OBJ_LOOKUP_ENTRY_FOR_PAGE(fs, free_pgndx) * sizeof(int16_t), sizeof(int16_t), (FAR uint8_t *)&objid); @@ -2029,7 +2029,6 @@ int spiffs_check_objidconsistency(FAR struct spiffs_s *fs) return ret; } - /**************************************************************************** * Name: spiffs_dump * @@ -2086,7 +2085,7 @@ int spiffs_dump(FAR struct spiffs_s *fs) cur_entry < (int)(SPIFFS_GEO_PAGES_PER_BLOCK(fs) - SPIFFS_OBJ_LOOKUP_PAGES(fs))) { - int16_t objid = objlu_buf[cur_entry-entry_offset]; + int16_t objid = objlu_buf[cur_entry - entry_offset]; if (cur_entry == 0) { @@ -2157,8 +2156,9 @@ int spiffs_dump(FAR struct spiffs_s *fs) spiffs_checkinfo("page_alloc: %d\n", fs->alloc_pages); spiffs_checkinfo("page_delet: %d\n", fs->deleted_pages); - /* The following duplicates some logic from spiffs_statfs() */ - /* -2 for spare blocks, +1 for emergency page */ + /* The following duplicates some logic from spiffs_statfs(). + * -2 for spare blocks, +1 for emergency page. + */ pages_per_block = SPIFFS_GEO_PAGES_PER_BLOCK(fs); blocks = SPIFFS_GEO_BLOCK_COUNT(fs); diff --git a/fs/spiffs/src/spiffs_core.c b/fs/spiffs/src/spiffs_core.c index c7c3dae2e74..370a611b8bc 100644 --- a/fs/spiffs/src/spiffs_core.c +++ b/fs/spiffs/src/spiffs_core.c @@ -1901,7 +1901,7 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs, /* On subsequent passes, create a new object index page */ len_objndx_spndx = - SPIFFS_OBJNDX_ENTRY_SPNDX(fs,(fobj->size - 1) / + SPIFFS_OBJNDX_ENTRY_SPNDX(fs, (fobj->size - 1) / SPIFFS_DATA_PAGE_SIZE(fs)); if (nwritten > 0 || cur_objndx_spndx > len_objndx_spndx) diff --git a/fs/spiffs/src/spiffs_gc.c b/fs/spiffs/src/spiffs_gc.c index db8feeeba24..8794ac32000 100644 --- a/fs/spiffs/src/spiffs_gc.c +++ b/fs/spiffs/src/spiffs_gc.c @@ -100,7 +100,6 @@ struct spiffs_gc_s * ****************************************************************************/ - static int spiffs_gc_erase_block(FAR struct spiffs_s *fs, int16_t blkndx) { int ret; @@ -109,6 +108,7 @@ static int spiffs_gc_erase_block(FAR struct spiffs_s *fs, int16_t blkndx) spiffs_gcinfo("Erase block=%04x\n", blkndx); /* Erase the block */ + ret = spiffs_erase_block(fs, blkndx); if (ret < 0) { @@ -332,7 +332,7 @@ static int spiffs_gc_find_candidate(FAR struct spiffs_s *fs, * probably not so many blocks */ - if (ret >= 0 /* && deleted_pages_in_block > 0 */ ) + if (ret >= 0 /* && deleted_pages_in_block > 0 */) { int32_t score; int16_t erase_count; @@ -754,7 +754,6 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx) */ } - if (ret < 0) { break; @@ -1134,7 +1133,7 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len) #if 0 if (fs->free_blocks <= 2 && (int32_t)needed_pages > free_pages) { - spiffs_gcinfo("Full freeblk=%d" needed=%d" free=%d dele=%d\n", + spiffs_gcinfo("Full freeblk=%d needed=%d free=%d dele=%d\n", fs->free_blocks, needed_pages, free_pages, fs->deleted_pages); return -ENOSPC; diff --git a/fs/spiffs/src/spiffs_vfs.c b/fs/spiffs/src/spiffs_vfs.c index 1c02282fb04..767dbfa8fc8 100644 --- a/fs/spiffs/src/spiffs_vfs.c +++ b/fs/spiffs/src/spiffs_vfs.c @@ -919,7 +919,6 @@ static off_t spiffs_seek(FAR struct file *filep, off_t offset, int whence) /* Set up for the new file position */ - data_spndx = (pos > 0 ? (pos - 1) : 0) / SPIFFS_DATA_PAGE_SIZE(fs); objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx); @@ -1127,7 +1126,7 @@ static int spiffs_dup(FAR const struct file *oldp, FAR struct file *newp) fobj = oldp->f_priv; - /* Increment the reference count (atomically)*/ + /* Increment the reference count (atomically) */ spiffs_lock_volume(fs); fobj->crefs++; @@ -1676,8 +1675,9 @@ static int spiffs_unlink(FAR struct inode *mountpt, FAR const char *relpath) } else { - /* Otherwise, we will need to re-open the file */ - /* Allocate new file object */ + /* Otherwise, we will need to re-open the file. + * First, allocate new file object. + */ fobj = (FAR struct spiffs_file_s *)kmm_zalloc(sizeof(struct spiffs_file_s)); if (fobj == NULL) diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c index a904433f11f..5d133ca5f5a 100644 --- a/fs/tmpfs/fs_tmpfs.c +++ b/fs/tmpfs/fs_tmpfs.c @@ -83,6 +83,7 @@ /**************************************************************************** * Private Function Prototypes ****************************************************************************/ + /* TMPFS helpers */ static void tmpfs_lock_reentrant(FAR struct tmpfs_sem_s *sem); @@ -1411,8 +1412,9 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath, goto errout_with_filelock; } - /* Check if the caller has sufficient privileges to open the file */ - /* REVISIT: No file protection implemented */ + /* Check if the caller has sufficient privileges to open the file. + * REVISIT: No file protection implemented + */ /* If O_TRUNC is specified and the file is opened for writing, * then truncate the file. This operation requires that the file is @@ -1770,7 +1772,7 @@ static int tmpfs_dup(FAR const struct file *oldp, FAR struct file *newp) tfo = oldp->f_priv; DEBUGASSERT(tfo != NULL); - /* Increment the reference count (atomically)*/ + /* Increment the reference count (atomically) */ tmpfs_lock_file(tfo); tfo->tfo_refs++; @@ -1810,7 +1812,7 @@ static int tmpfs_fstat(FAR const struct file *filep, FAR struct stat *buf) tmpfs_lock_file(tfo); - /* Return information about the file in the stat buffer.*/ + /* Return information about the file in the stat buffer. */ tmpfs_stat_common((FAR struct tmpfs_object_s *)tfo, buf); diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c index 4f11a596462..7367d696f6e 100644 --- a/fs/unionfs/fs_unionfs.c +++ b/fs/unionfs/fs_unionfs.c @@ -78,6 +78,7 @@ /**************************************************************************** * Private Types ****************************************************************************/ + /* This structure describes one contained file system mountpoint */ struct unionfs_mountpt_s @@ -107,6 +108,7 @@ struct unionfs_file_s /**************************************************************************** * Private Function Prototypes ****************************************************************************/ + /* Helper functions */ static int unionfs_semtake(FAR struct unionfs_inode_s *ui, bool noint); @@ -358,7 +360,6 @@ static bool unionfs_ispartprefix(FAR const char *partprefix, /* Check for NUL or empty full prefix */ - if (prefix == NULL || *prefix == '\0') { /* A non-NUL partial path cannot be a contained in a NUL prefix */ @@ -703,7 +704,7 @@ static FAR char *unionfs_relpath(FAR const char *path, FAR const char *name) { /* Yes.. extend the file name by prepending the path */ - if (path[pathlen-1] == '/') + if (path[pathlen - 1] == '/') { ret = asprintf(&relpath, "%s%s", path, name); } @@ -1715,7 +1716,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) * directories. */ - strncpy(dir->fd_dir.d_name, um->um_prefix, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, um->um_prefix, NAME_MAX + 1); /* Describe this as a read only directory */ @@ -1789,7 +1790,7 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) * be multiple directories. */ - strncpy(dir->fd_dir.d_name, um->um_prefix, NAME_MAX+1); + strncpy(dir->fd_dir.d_name, um->um_prefix, NAME_MAX + 1); /* Describe this as a read only directory */ diff --git a/fs/userfs/fs_userfs.c b/fs/userfs/fs_userfs.c index 45ff7f663c1..d76f1c93d47 100644 --- a/fs/userfs/fs_userfs.c +++ b/fs/userfs/fs_userfs.c @@ -1377,7 +1377,7 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR const void *data, client.sin_port = 0; client.sin_addr.s_addr = HTONL(INADDR_LOOPBACK); - ret = psock_bind(&priv->psock, (struct sockaddr*)&client, + ret = psock_bind(&priv->psock, (FAR struct sockaddr *)&client, sizeof(struct sockaddr_in)); if (ret < 0) { diff --git a/fs/vfs/fs_dup.c b/fs/vfs/fs_dup.c index 7bdbec390db..80f847f699e 100644 --- a/fs/vfs/fs_dup.c +++ b/fs/vfs/fs_dup.c @@ -63,7 +63,8 @@ int dup(int fd) int ret = OK; /* Check the range of the descriptor to see if we got a file or a socket - * descriptor. */ + * descriptor. + */ if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) { diff --git a/fs/vfs/fs_dupfd2.c b/fs/vfs/fs_dupfd2.c index 93f044b8843..0d0f35cf8ad 100644 --- a/fs/vfs/fs_dupfd2.c +++ b/fs/vfs/fs_dupfd2.c @@ -130,4 +130,3 @@ errout: set_errno(-ret); return ERROR; } - diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index 69cd50170dd..ca9a6bfdccd 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -142,7 +142,7 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) { if (eph->evs[i].data.fd == fd) { - if (i != eph->occupied-1) + if (i != eph->occupied - 1) { memmove(&eph->evs[i], &eph->evs[i + 1], eph->occupied - i); diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 0fda254e151..6319ad96a5a 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -107,7 +107,8 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup) /* Perform the socket ioctl */ #ifdef CONFIG_NET - if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) + if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + + CONFIG_NSOCKET_DESCRIPTORS)) { return net_poll(fd, fds, setup); } @@ -478,18 +479,20 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) #if (MSEC_PER_TICK * USEC_PER_MSEC) != USEC_PER_TICK && \ defined(CONFIG_HAVE_LONG_LONG) - ticks = (((unsigned long long)timeout * USEC_PER_MSEC) + (USEC_PER_TICK - 1)) / + ticks = (((unsigned long long)timeout * USEC_PER_MSEC) + + (USEC_PER_TICK - 1)) / USEC_PER_TICK; #else - ticks = ((unsigned int)timeout + (MSEC_PER_TICK - 1)) / MSEC_PER_TICK; + ticks = ((unsigned int)timeout + (MSEC_PER_TICK - 1)) / + MSEC_PER_TICK; #endif /* Either wait for either a poll event(s), for a signal to occur, * or for the specified timeout to elapse with no event. * - * NOTE: If a poll event is pending (i.e., the semaphore has already - * been incremented), nxsem_tickwait() will not wait, but will return - * immediately. + * NOTE: If a poll event is pending (i.e., the semaphore has + * already been incremented), nxsem_tickwait() will not wait, but + * will return immediately. */ ret = nxsem_tickwait(&sem, clock_systimer(), ticks); @@ -512,8 +515,8 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) ret = poll_semtake(&sem); } - /* Teardown the poll operation and get the count of events. Zero will be - * returned in the case of a timeout. + /* Teardown the poll operation and get the count of events. Zero will + * be returned in the case of a timeout. * * Preserve ret, if negative, since it holds the result of the wait. */ diff --git a/fs/vfs/fs_rename.c b/fs/vfs/fs_rename.c index d0c074ae459..627abba7a9f 100644 --- a/fs/vfs/fs_rename.c +++ b/fs/vfs/fs_rename.c @@ -390,7 +390,7 @@ next_subdir: { FAR char *subdirname; - /* Yes.. In this case, the target of the rename must be a + /* Yes.. In this case, the target of the rename must be a * subdirectory of newinode, not the newinode itself. For * example: mv b a/ must move b to a/b. */ @@ -414,7 +414,8 @@ next_subdir: FAR char *tmp = subdir; subdir = NULL; - (void)asprintf(&subdir, "%s/%s", newrelpath, subdirname); + (void)asprintf(&subdir, "%s/%s", newrelpath, + subdirname); if (tmp != NULL) { diff --git a/fs/vfs/fs_rmdir.c b/fs/vfs/fs_rmdir.c index d75c83a7e19..33706756df3 100644 --- a/fs/vfs/fs_rmdir.c +++ b/fs/vfs/fs_rmdir.c @@ -137,8 +137,8 @@ int rmdir(FAR const char *pathname) #endif #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - /* If this is a "dangling" pseudo-directory node (i.e., it has no operations) - * then rmdir should remove the node. + /* If this is a "dangling" pseudo-directory node (i.e., it has no + * operations) then rmdir should remove the node. */ if (!inode->u.i_ops)