diff --git a/fs/binfs/fs_binfs.c b/fs/binfs/fs_binfs.c index 5e5a09f576..8cd8b7e5c5 100644 --- a/fs/binfs/fs_binfs.c +++ b/fs/binfs/fs_binfs.c @@ -425,13 +425,14 @@ static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *b /* It's a execute-only file name */ - buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR; + buf->st_mode = S_IFREG | S_IXOTH | S_IXGRP | S_IXUSR; } else { /* It's a read/execute-only directory name */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IXOTH|S_IXGRP|S_IXUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR | S_IXOTH | + S_IXGRP | S_IXUSR; } /* File/directory size, access block size */ diff --git a/fs/dirent/fs_opendir.c b/fs/dirent/fs_opendir.c index 00876012c6..5731ba632b 100644 --- a/fs/dirent/fs_opendir.c +++ b/fs/dirent/fs_opendir.c @@ -261,7 +261,7 @@ FAR DIR *opendir(FAR const char *path) if (!inode) { - /* 'path' is not a does not exist.*/ + /* 'path' is not a does not exist. */ ret = ENOTDIR; goto errout_with_semaphore; @@ -274,7 +274,7 @@ FAR DIR *opendir(FAR const char *path) dir = (FAR struct fs_dirent_s *)kumm_zalloc(sizeof(struct fs_dirent_s)); if (!dir) { - /* Insufficient memory to complete the operation.*/ + /* Insufficient memory to complete the operation. */ ret = ENOMEM; goto errout_with_semaphore; @@ -350,7 +350,7 @@ FAR DIR *opendir(FAR const char *path) } inode_semgive(); - return ((DIR*)dir); + return ((FAR DIR *)dir); /* Nasty goto's make error handling simpler */ diff --git a/fs/dirent/fs_seekdir.c b/fs/dirent/fs_seekdir.c index f58274f43a..761dba33cd 100644 --- a/fs/dirent/fs_seekdir.c +++ b/fs/dirent/fs_seekdir.c @@ -68,7 +68,7 @@ static inline void seekpseudodir(struct fs_dirent_s *idir, off_t offset) * "rewind" to the root dir. */ - if ( offset < idir->fd_position ) + if (offset < idir->fd_position) { pos = 0; curr = idir->fd_root; @@ -126,7 +126,7 @@ static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset) */ inode = idir->fd_root; - if ( offset < idir->fd_position ) + if (offset < idir->fd_position) { if (inode->u.i_mops && inode->u.i_mops->rewinddir) { diff --git a/fs/driver/fs_devsyslog.c b/fs/driver/fs_devsyslog.c index 991506fe0f..70b21a2c08 100644 --- a/fs/driver/fs_devsyslog.c +++ b/fs/driver/fs_devsyslog.c @@ -108,7 +108,10 @@ struct syslog_dev_s /* This is the device structure for the console or syslogging function. */ static struct syslog_dev_s g_sysdev; -static const uint8_t g_syscrlf[2] = { '\r', '\n' }; +static const uint8_t g_syscrlf[2] = +{ + '\r', '\n' +}; /**************************************************************************** * Private Functions diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index e4dfbe19b8..95a6ce04d5 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -229,7 +229,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath, /* It would be an error if we are asked to create it exclusively */ - if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { /* Already exists -- can't create it exclusively */ @@ -256,7 +256,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath, * access is ignored. */ - if ((oflags & (O_TRUNC|O_WRONLY)) == (O_TRUNC|O_WRONLY)) + if ((oflags & (O_TRUNC | O_WRONLY)) == (O_TRUNC | O_WRONLY)) { /* Truncate the file to zero length */ @@ -314,7 +314,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath, * file. */ - ff = (struct fat_file_s *)kmm_zalloc(sizeof(struct fat_file_s)); + ff = (FAR struct fat_file_s *)kmm_zalloc(sizeof(struct fat_file_s)); if (!ff) { ret = -ENOMEM; @@ -323,7 +323,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath, /* Create a file buffer to support partial sector accesses */ - ff->ff_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize); + ff->ff_buffer = (FAR uint8_t *)fat_io_alloc(fs->fs_hwsectorsize); if (!ff->ff_buffer) { ret = -ENOMEM; @@ -366,7 +366,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath, /* In write/append mode, we need to set the file pointer to the end of the file */ - if ((oflags & (O_APPEND|O_WRONLY)) == (O_APPEND|O_WRONLY)) + if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY)) { off_t offset = fat_seek(filep, ff->ff_size, SEEK_SET); if (offset < 0) @@ -482,7 +482,7 @@ static ssize_t fat_read(FAR struct file *filep, FAR char *buffer, unsigned int nsectors; size_t bytesleft; int32_t cluster; - FAR uint8_t *userbuffer = (uint8_t*)buffer; + FAR uint8_t *userbuffer = (FAR uint8_t *)buffer; int sectorindex; int ret; bool force_indirect = false; @@ -710,7 +710,7 @@ static ssize_t fat_write(FAR struct file *filep, FAR const char *buffer, unsigned int byteswritten; unsigned int writesize; unsigned int nsectors; - FAR uint8_t *userbuffer = (uint8_t*)buffer; + FAR uint8_t *userbuffer = (FAR uint8_t *)buffer; int sectorindex; int ret; bool force_indirect = false; @@ -970,7 +970,7 @@ fat_write_restart: */ memcpy(&ff->ff_buffer[sectorindex], userbuffer, writesize); - ff->ff_bflags |= (FFBUFF_DIRTY|FFBUFF_VALID|FFBUFF_MODIFIED); + ff->ff_bflags |= (FFBUFF_DIRTY | FFBUFF_VALID | FFBUFF_MODIFIED); } /* Set up for the next write */ @@ -1119,7 +1119,7 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence) */ clustersize = fs->fs_fatsecperclus * fs->fs_hwsectorsize; - for (;;) + for (; ; ) { /* Skip over clusters prior to the one containing * the requested position. @@ -1436,7 +1436,7 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp) * dup'ed file. */ - newff = (struct fat_file_s *)kmm_malloc(sizeof(struct fat_file_s)); + newff = (FAR struct fat_file_s *)kmm_malloc(sizeof(struct fat_file_s)); if (!newff) { ret = -ENOMEM; @@ -1445,7 +1445,7 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp) /* Create a file buffer to support partial sector accesses */ - newff->ff_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize); + newff->ff_buffer = (FAR uint8_t *)fat_io_alloc(fs->fs_hwsectorsize); if (!newff->ff_buffer) { ret = -ENOMEM; @@ -1873,7 +1873,7 @@ static int fat_bind(FAR struct inode *blkdriver, FAR const void *data, return ret; } - *handle = (void*)fs; + *handle = (FAR void *)fs; fat_semgive(fs); return OK; } @@ -1889,7 +1889,7 @@ static int fat_bind(FAR struct inode *blkdriver, FAR const void *data, static int fat_unbind(FAR void *handle, FAR struct inode **blkdriver, unsigned int flags) { - FAR struct fat_mountpt_s *fs = (FAR struct fat_mountpt_s*)handle; + FAR struct fat_mountpt_s *fs = (FAR struct fat_mountpt_s *)handle; if (!fs) { @@ -2525,7 +2525,8 @@ static int fat_stat(FAR struct inode *mountpt, FAR const char *relpath, { /* It's directory name of the mount point */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IWOTH|S_IWGRP|S_IWUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR | S_IWOTH | + S_IWGRP | S_IWUSR; ret = OK; goto errout_with_semaphore; } @@ -2544,10 +2545,10 @@ static int fat_stat(FAR struct inode *mountpt, FAR const char *relpath, * by everyone but may be writeable by no-one. */ - buf->st_mode = S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IROTH | S_IRGRP | S_IRUSR; if ((attribute & FATATTR_READONLY) == 0) { - buf->st_mode |= S_IWOTH|S_IWGRP|S_IWUSR; + buf->st_mode |= S_IWOTH | S_IWGRP | S_IWUSR; } /* We will report only types file or directory */ diff --git a/fs/fat/fs_fat32attrib.c b/fs/fat/fs_fat32attrib.c index 1880dc6819..ef9b90b474 100644 --- a/fs/fat/fs_fat32attrib.c +++ b/fs/fat/fs_fat32attrib.c @@ -128,8 +128,10 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib, /* Set or clear any bits as requested */ - newattributes &= ~(clearbits & (FATATTR_READONLY|FATATTR_HIDDEN|FATATTR_SYSTEM|FATATTR_ARCHIVE)); - newattributes |= (setbits & (FATATTR_READONLY|FATATTR_HIDDEN|FATATTR_SYSTEM|FATATTR_ARCHIVE)); + newattributes &= ~(clearbits & (FATATTR_READONLY | FATATTR_HIDDEN | + FATATTR_SYSTEM | FATATTR_ARCHIVE)); + newattributes |= (setbits & (FATATTR_READONLY | FATATTR_HIDDEN | + FATATTR_SYSTEM | FATATTR_ARCHIVE)); /* Did any thingchange? */ diff --git a/fs/fat/fs_fat32dirent.c b/fs/fat/fs_fat32dirent.c index 9d349c9495..586c60d8ee 100644 --- a/fs/fat/fs_fat32dirent.c +++ b/fs/fat/fs_fat32dirent.c @@ -271,7 +271,7 @@ static inline int fat_parsesfname(const char **path, /* Loop until the name is successfully parsed or an error occurs */ endndx = 8; - for (;;) + for (; ; ) { /* Get the next byte from the path */ @@ -279,7 +279,7 @@ static inline int fat_parsesfname(const char **path, /* Check if this the last byte in this node of the name */ - if ((ch == '\0' || ch == '/') && ndx != 0 ) + if ((ch == '\0' || ch == '/') && ndx != 0) { /* Return the accumulated NT flags and the terminating character */ @@ -348,12 +348,12 @@ static inline int fat_parsesfname(const char **path, goto errout; } - /* So far, only upper case in the name*/ + /* So far, only upper case in the name */ namecase = FATCASE_UPPER; #endif - /* Clear lower case name bit in mask*/ + /* Clear lower case name bit in mask */ ntlcenable &= ~FATNTRES_LCNAME; } @@ -369,7 +369,7 @@ static inline int fat_parsesfname(const char **path, goto errout; } - /* So far, only upper case in the extension*/ + /* So far, only upper case in the extension */ extcase = FATCASE_UPPER; #endif @@ -415,7 +415,7 @@ static inline int fat_parsesfname(const char **path, goto errout; } - /* So far, only lower case in the name*/ + /* So far, only lower case in the name */ namecase = FATCASE_LOWER; #endif @@ -436,7 +436,7 @@ static inline int fat_parsesfname(const char **path, goto errout; } - /* So far, only lower case in the extension*/ + /* So far, only lower case in the extension */ extcase = FATCASE_LOWER; #endif @@ -503,7 +503,7 @@ static inline int fat_parselfname(const char **path, /* Loop until the name is successfully parsed or an error occurs */ - for (;;) + for (; ; ) { /* Get the next byte from the path */ @@ -511,7 +511,7 @@ static inline int fat_parselfname(const char **path, /* Check if this the last byte in this node of the name */ - if ((ch == '\0' || ch == '/') && ndx != 0 ) + if ((ch == '\0' || ch == '/') && ndx != 0) { /* Null terminate the string */ @@ -594,8 +594,8 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo) /* First, let's decide what is name and what is extension */ - len = strlen((char*)dirinfo->fd_lfname); - ext = strrchr((char*)dirinfo->fd_lfname, '.'); + len = strlen((FAR char *)dirinfo->fd_lfname); + ext = strrchr((FAR char *)dirinfo->fd_lfname, '.'); if (ext) { ptrdiff_t tmp; @@ -604,7 +604,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo) * beginning of the string is then the name length. */ - tmp = ext - (char*)dirinfo->fd_lfname; + tmp = ext - (FAR char *)dirinfo->fd_lfname; namechars = tmp; /* And the rest, excluding the '.' is the extension. */ @@ -656,7 +656,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo) } else { - src = (char*)dirinfo->fd_lfname; + src = (FAR char *)dirinfo->fd_lfname; } /* Then copy the name and extension, handling upper case conversions and @@ -666,7 +666,7 @@ static inline int fat_createalias(struct fat_dirinfo_s *dirinfo) ndx = 0; /* Position to write the next name character */ endndx = 6; /* Maximum index before we write ~! and switch to the extension */ - for (;;) + for (; ; ) { /* Get the next byte from the path. Break out of the loop if we * encounter the end of null-terminated the long file name string. @@ -991,7 +991,7 @@ static int fat_findsfnentry(struct fat_mountpt_s *fs, * the matching short name */ - for (;;) + for (; ; ) { /* Read the next sector into memory */ @@ -1017,7 +1017,7 @@ static int fat_findsfnentry(struct fat_mountpt_s *fs, if (direntry[DIR_NAME] != DIR0_EMPTY && !(DIR_GETATTRIBUTES(direntry) & FATATTR_VOLUMEID) && - !memcmp(&direntry[DIR_NAME], dirinfo->fd_name, DIR_MAXFNAME) ) + !memcmp(&direntry[DIR_NAME], dirinfo->fd_name, DIR_MAXFNAME)) { /* Yes.. Return success */ @@ -1085,7 +1085,7 @@ static bool fat_cmplfnchunk(uint8_t *chunk, const uint8_t *substr, int nchunk) * should match the ASCII code. */ - wch = (wchar_t)fat_getuint16((uint8_t*)chunk); + wch = (wchar_t)fat_getuint16((FAR uint8_t *)chunk); if ((wch & 0xff) != (wchar_t)ch) { return false; @@ -1130,7 +1130,7 @@ static bool fat_cmplfname(const uint8_t *direntry, const uint8_t *substr) * terminator). */ - len = strlen((char*)substr) + 1; + len = strlen((FAR char *)substr) + 1; /* Check bytes 1-5 */ @@ -1186,7 +1186,7 @@ static inline int fat_findlfnentry(struct fat_mountpt_s *fs, * LDIR_MAXFNAME+1 we do not have to check the length of the string). */ - namelen = strlen((char*)dirinfo->fd_lfname); + namelen = strlen((FAR char *)dirinfo->fd_lfname); DEBUGASSERT(namelen <= LDIR_MAXFNAME+1); /* How many LFN directory entries are we expecting? */ @@ -1219,7 +1219,7 @@ static inline int fat_findlfnentry(struct fat_mountpt_s *fs, * the match shore name */ - for (;;) + for (; ; ) { /* Read the next sector into memory */ @@ -1406,7 +1406,7 @@ static inline int fat_allocatesfnentry(struct fat_mountpt_s *fs, /* Then search for a free short file name directory entry */ - for (;;) + for (; ; ) { /* Read the directory sector into fs_buffer */ @@ -1518,7 +1518,7 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs, */ needed = nentries; - for (;;) + for (; ; ) { /* Read the directory sector into fs_buffer */ @@ -1613,111 +1613,111 @@ static inline int fat_getsfname(uint8_t *direntry, char *buffer, unsigned int buflen) { #ifdef CONFIG_FAT_LCNAMES - uint8_t ntflags; + uint8_t ntflags; #endif - int ch; - int ndx; + int ch; + int ndx; - /* Check if we will be doing upper to lower case conversions */ + /* Check if we will be doing upper to lower case conversions */ #ifdef CONFIG_FAT_LCNAMES - ntflags = DIR_GETNTRES(direntry); + ntflags = DIR_GETNTRES(direntry); #endif - /* Reserve a byte for the NUL terminator */ + /* Reserve a byte for the NUL terminator */ - buflen--; + buflen--; - /* Get the 8-byte filename */ + /* Get the 8-byte filename */ - for (ndx = 0; ndx < 8 && buflen > 0; ndx++) - { - /* Get the next filename character from the directory entry */ + for (ndx = 0; ndx < 8 && buflen > 0; ndx++) + { + /* Get the next filename character from the directory entry */ - ch = direntry[ndx]; + ch = direntry[ndx]; - /* Any space (or ndx==8) terminates the filename */ + /* Any space (or ndx==8) terminates the filename */ - if (ch == ' ') - { - break; - } + if (ch == ' ') + { + break; + } - /* In this version, we never write 0xe5 in the directory filenames - * (because we do not handle any character sets where 0xe5 is valid - * in a filaname), but we could encounted this in a filesystem - * written by some other system - */ + /* In this version, we never write 0xe5 in the directory filenames + * (because we do not handle any character sets where 0xe5 is valid + * in a filaname), but we could encounted this in a filesystem + * written by some other system + */ - if (ndx == 0 && ch == DIR0_E5) - { - ch = 0xe5; - } + if (ndx == 0 && ch == DIR0_E5) + { + ch = 0xe5; + } - /* Check if we should perform upper to lower case conversion - * of the (whole) filename. - */ + /* Check if we should perform upper to lower case conversion + * of the (whole) filename. + */ #ifdef CONFIG_FAT_LCNAMES - if (ntflags & FATNTRES_LCNAME && isupper(ch)) - { - ch = tolower(ch); - } + if (ntflags & FATNTRES_LCNAME && isupper(ch)) + { + ch = tolower(ch); + } #endif - /* Copy the next character into the filename */ + /* Copy the next character into the filename */ - *buffer++ = ch; - buflen--; - } + *buffer++ = ch; + buflen--; + } - /* Check if there is an extension */ + /* Check if there is an extension */ - if (direntry[8] != ' ' && buflen > 0) - { - /* Yes, output the dot before the extension */ + if (direntry[8] != ' ' && buflen > 0) + { + /* Yes, output the dot before the extension */ - *buffer++ = '.'; - buflen--; + *buffer++ = '.'; + buflen--; - /* Then output the (up to) 3 character extension */ + /* Then output the (up to) 3 character extension */ - for (ndx = 8; ndx < 11 && buflen > 0; ndx++) - { - /* Get the next extensions character from the directory entry */ + for (ndx = 8; ndx < 11 && buflen > 0; ndx++) + { + /* Get the next extensions character from the directory entry */ - ch = direntry[DIR_NAME + ndx]; + ch = direntry[DIR_NAME + ndx]; - /* Any space (or ndx==11) terminates the extension */ + /* Any space (or ndx==11) terminates the extension */ - if (ch == ' ') - { - break; - } + if (ch == ' ') + { + break; + } - /* Check if we should perform upper to lower case conversion - * of the (whole) filename. - */ + /* Check if we should perform upper to lower case conversion + * of the (whole) filename. + */ #ifdef CONFIG_FAT_LCNAMES - if (ntflags & FATNTRES_LCEXT && isupper(ch)) - { - ch = tolower(ch); - } + if (ntflags & FATNTRES_LCEXT && isupper(ch)) + { + ch = tolower(ch); + } #endif - /* Copy the next character into the filename */ + /* Copy the next character into the filename */ - *buffer++ = ch; - buflen--; - } - } + *buffer++ = ch; + buflen--; + } + } - /* Put a null terminator at the end of the filename. We don't have to - * check if there is room because we reserved a byte for the NUL - * terminator at the beginning of this function. - */ + /* Put a null terminator at the end of the filename. We don't have to + * check if there is room because we reserved a byte for the NUL + * terminator at the beginning of this function. + */ - *buffer = '\0'; - return OK; + *buffer = '\0'; + return OK; } /**************************************************************************** @@ -1798,7 +1798,7 @@ static inline int fat_getlfname(struct fat_mountpt_s *fs, struct fs_dirent_s *di /* Loop until the whole file name has been transferred */ - for (;;) + for (; ; ) { /* Get the string offset associated with the "last" entry. */ @@ -2028,7 +2028,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, * LDIR_MAXLFNCHARS (13). */ - namelen = strlen((char*)dirinfo->fd_lfname); + namelen = strlen((FAR char *)dirinfo->fd_lfname); DEBUGASSERT(namelen <= LDIR_MAXFNAME+1); /* How many LFN directory entries do we need to write? */ @@ -2093,7 +2093,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, /* Now loop, writing each long file name entry */ - for (;;) + for (; ; ) { /* Get the string offset associated with the directory entry. */ @@ -2314,7 +2314,7 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo, /* Now loop until the directory entry corresponding to the path is found */ - for (;;) + for (; ; ) { /* Convert the next the path segment name into the kind of name that * we would see in the directory entry. @@ -2441,7 +2441,7 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs, * or until to fail to extend the directory cluster chain. */ - for (;;) + for (; ; ) { /* Can this cluster chain be extended */ @@ -2520,9 +2520,9 @@ int fat_allocatedirentry(struct fat_mountpt_s *fs, return cluster; } - /* Flush out any cached data in fs_buffer.. we are going to use - * it to initialize the new directory cluster. - */ + /* Flush out any cached data in fs_buffer.. we are going to use + * it to initialize the new directory cluster. + */ ret = fat_fscacheflush(fs); if (ret < 0) @@ -2591,7 +2591,7 @@ int fat_freedirentry(struct fat_mountpt_s *fs, struct fat_dirseq_s *seq) * and for the single short file name entry. */ - for (;;) + for (; ; ) { /* Read the directory sector into the sector cache */ @@ -2896,7 +2896,7 @@ int fat_remove(struct fat_mountpt_s *fs, const char *relpath, bool directory) * (2) the directory is found to be empty, or (3) some error occurs. */ - for (;;) + for (; ; ) { unsigned int subdirindex; uint8_t *subdirentry; diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c index 3d70032582..380facb313 100644 --- a/fs/fat/fs_fat32util.c +++ b/fs/fat/fs_fat32util.c @@ -322,9 +322,9 @@ uint32_t fat_getuint32(uint8_t *ptr) * Name: fat_putuint16 ****************************************************************************/ -void fat_putuint16(uint8_t *ptr, uint16_t value16) +void fat_putuint16(FAR uint8_t *ptr, uint16_t value16) { - uint8_t *val = (uint8_t*)&value16; + FAR uint8_t *val = (FAR uint8_t *)&value16; #ifdef CONFIG_ENDIAN_BIG /* If the target is big-endian then the bytes always have to be swapped so @@ -348,9 +348,9 @@ void fat_putuint16(uint8_t *ptr, uint16_t value16) * Name: fat_putuint32 ****************************************************************************/ -void fat_putuint32(uint8_t *ptr, uint32_t value32) +void fat_putuint32(FAR uint8_t *ptr, uint32_t value32) { - uint16_t *val = (uint16_t*)&value32; + FAR uint16_t *val = (FAR uint16_t *)&value32; #ifdef CONFIG_ENDIAN_BIG /* If the target is big-endian then the bytes always have to be swapped so @@ -554,7 +554,7 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) /* Allocate a buffer to hold one hardware sector */ - fs->fs_buffer = (uint8_t*)fat_io_alloc(fs->fs_hwsectorsize); + fs->fs_buffer = (FAR uint8_t *)fat_io_alloc(fs->fs_hwsectorsize); if (!fs->fs_buffer) { ret = -ENOMEM; @@ -585,12 +585,12 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) * indexed by 16x the partition number. */ - 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. - */ + 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); fvdbg("Partition %d, offset %d, type %d\n", i, PART_ENTRY(i), part); @@ -748,7 +748,7 @@ int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector, unsigned int nsectors) { int ret = -ENODEV; - if (fs && fs->fs_blkdriver ) + if (fs && fs->fs_blkdriver) { struct inode *inode = fs->fs_blkdriver; if (inode && inode->u.i_bops && inode->u.i_bops->read) @@ -781,7 +781,7 @@ int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector, unsigned int nsectors) { int ret = -ENODEV; - if (fs && fs->fs_blkdriver ) + if (fs && fs->fs_blkdriver) { struct inode *inode = fs->fs_blkdriver; if (inode && inode->u.i_bops && inode->u.i_bops->write) @@ -811,7 +811,7 @@ int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, off_t sector, * ****************************************************************************/ -off_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32_t cluster ) +off_t fat_cluster2sector(FAR struct fat_mountpt_s *fs, uint32_t cluster) { cluster -= 2; if (cluster >= fs->fs_nclusters - 2) @@ -993,7 +993,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno, /* Make sure that the sector at this offset is in the cache */ - if (fat_fscacheread(fs, fatsector)< 0) + if (fat_fscacheread(fs, fatsector) < 0) { /* Read error */ @@ -1239,7 +1239,7 @@ int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster) */ newcluster = startcluster; - for (;;) + for (; ; ) { /* Examine the next cluster in the FAT */ @@ -1303,7 +1303,7 @@ int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster) return ret; } - /* And link if to the start cluster (if any)*/ + /* And link if to the start cluster (if any) */ if (cluster) { @@ -1563,29 +1563,29 @@ int fat_fscacheread(struct fat_mountpt_s *fs, off_t sector) * we do nothing. Otherwise, we will have to read the new sector. */ - if (fs->fs_currentsector != sector) - { - /* We will need to read the new sector. First, flush the cached - * sector if it is dirty. - */ + if (fs->fs_currentsector != sector) + { + /* We will need to read the new sector. First, flush the cached + * sector if it is dirty. + */ - ret = fat_fscacheflush(fs); - if (ret < 0) - { - return ret; - } + ret = fat_fscacheflush(fs); + if (ret < 0) + { + return ret; + } - /* Then read the specified sector into the cache */ + /* Then read the specified sector into the cache */ - ret = fat_hwread(fs, fs->fs_buffer, sector, 1); - if (ret < 0) - { - return ret; - } + ret = fat_hwread(fs, fs->fs_buffer, sector, 1); + if (ret < 0) + { + return ret; + } - /* Update the cached sector number */ + /* Update the cached sector number */ - fs->fs_currentsector = sector; + fs->fs_currentsector = sector; } return OK; @@ -1608,7 +1608,8 @@ int fat_ffcacheflush(struct fat_mountpt_s *fs, struct fat_file_s *ff) */ if (ff->ff_cachesector && - (ff->ff_bflags & (FFBUFF_DIRTY|FFBUFF_VALID)) == (FFBUFF_DIRTY|FFBUFF_VALID)) + (ff->ff_bflags & (FFBUFF_DIRTY | FFBUFF_VALID)) == + (FFBUFF_DIRTY | FFBUFF_VALID)) { /* Write the dirty sector */ @@ -1875,7 +1876,7 @@ int fat_currentsector(struct fat_mountpt_s *fs, struct fat_file_s *ff, { int sectoroffset; - if (position <= ff->ff_size ) + if (position <= ff->ff_size) { /* sectoroffset is the sector number offset into the current cluster */ @@ -1883,7 +1884,7 @@ int fat_currentsector(struct fat_mountpt_s *fs, struct fat_file_s *ff, /* The current cluster is the first sector of the cluster plus * the sector offset - */ + */ ff->ff_currentsector = fat_cluster2sector(fs, ff->ff_currentcluster) + sectoroffset; diff --git a/fs/fat/fs_mkfatfs.c b/fs/fat/fs_mkfatfs.c index 08eb618c2b..a1f17d7374 100644 --- a/fs/fat/fs_mkfatfs.c +++ b/fs/fat/fs_mkfatfs.c @@ -299,9 +299,9 @@ int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt) /* Allocate a buffer that will be working sector memory */ #ifdef CONFIG_FAT_DMAMEMORY - var.fv_sect = (uint8_t*)fat_dma_alloc(var.fv_sectorsize); + var.fv_sect = (FAR uint8_t *)fat_dma_alloc(var.fv_sectorsize); #else - var.fv_sect = (uint8_t*)kmm_malloc(var.fv_sectorsize); + var.fv_sect = (FAR uint8_t *)kmm_malloc(var.fv_sectorsize); #endif if (!var.fv_sect) diff --git a/fs/fat/fs_writefat.c b/fs/fat/fs_writefat.c index 51e71e278d..a484cbac67 100644 --- a/fs/fat/fs_writefat.c +++ b/fs/fat/fs_writefat.c @@ -81,7 +81,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt, /* 8@3: Usually "MSWIN4.1" */ - strcpy((char*)&var->fv_sect[BS_OEMNAME], "NUTTX "); + strcpy((FAR char *)&var->fv_sect[BS_OEMNAME], "NUTTX "); /* 2@11: Bytes per sector: 512, 1024, 2048, 4096 */ @@ -177,7 +177,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt, MBR_PUTFATSZ32(var->fv_sect, var->fv_nfatsects); - /* 2@40: 0-3:Active FAT, 7=0 both FATS, 7=1 one FAT -- left zero*/ + /* 2@40: 0-3:Active FAT, 7=0 both FATS, 7=1 one FAT -- left zero */ /* 2@42: MSB:Major LSB:Minor revision number (0.0) -- left zero */ /* 4@44: Cluster no. of 1st cluster of root dir */ @@ -357,7 +357,7 @@ static inline int mkfatfs_writembr(FAR struct fat_format_s *fmt, if (ret >= 0) { - /* Create an image of the fsinfo sector*/ + /* Create an image of the fsinfo sector */ mkfatfs_initfsinfo(fmt, var); @@ -408,7 +408,7 @@ static inline int mkfatfs_writefat(FAR struct fat_format_s *fmt, if (sectno == 0) { memset(var->fv_sect, 0, var->fv_sectorsize); - switch(fmt->ff_fattype) + switch (fmt->ff_fattype) { case 12: /* Mark the first two full FAT entries -- 24 bits, 3 bytes total */ diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index 4f82b15126..a35526232d 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -385,7 +385,7 @@ void files_release(int fd) list = sched_getfiles(); DEBUGASSERT(list); - if (fd >=0 && fd < CONFIG_NFILE_DESCRIPTORS) + if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) { _files_semtake(list); list->fl_files[fd].f_oflags = 0; diff --git a/fs/inode/fs_inode.c b/fs/inode/fs_inode.c index d5d58102ea..2e3edc4c1d 100644 --- a/fs/inode/fs_inode.c +++ b/fs/inode/fs_inode.c @@ -111,7 +111,7 @@ static int _inode_compare(FAR const char *fname, return -1; } - for (;;) + for (; ; ) { /* At end of node name? */ @@ -133,7 +133,7 @@ static int _inode_compare(FAR const char *fname, } } - /* At end of find name?*/ + /* At end of find name? */ else if (!*fname || *fname == '/') { @@ -421,19 +421,19 @@ FAR const char *inode_nextname(FAR const char *name) * path segment. */ - while (*name && *name != '/') - { - name++; - } + while (*name && *name != '/') + { + name++; + } - /* If we found the '/' delimiter, then the path segment we want begins at - * the next character (which might also be the NUL terminator). - */ + /* If we found the '/' delimiter, then the path segment we want begins at + * the next character (which might also be the NUL terminator). + */ - if (*name) - { - name++; - } + if (*name) + { + name++; + } - return name; + return name; } diff --git a/fs/inode/fs_inodebasename.c b/fs/inode/fs_inodebasename.c index afd1e56592..6398d9854c 100644 --- a/fs/inode/fs_inodebasename.c +++ b/fs/inode/fs_inodebasename.c @@ -74,7 +74,7 @@ FAR const char *inode_basename(FAR const char *name) { FAR const char *basename = NULL; - for (;;) + for (; ; ) { /* Get the name for the next path segment */ diff --git a/fs/inode/fs_inodereserve.c b/fs/inode/fs_inodereserve.c index a241cef0e4..5e674783df 100644 --- a/fs/inode/fs_inodereserve.c +++ b/fs/inode/fs_inodereserve.c @@ -70,7 +70,11 @@ static int inode_namelen(FAR const char *name) { const char *tmp = name; - while (*tmp && *tmp != '/') tmp++; + while (*tmp && *tmp != '/') + { + tmp++; + } + return tmp - name; } @@ -80,8 +84,12 @@ static int inode_namelen(FAR const char *name) static void inode_namecpy(char *dest, const char *src) { - while (*src && *src != '/') *dest++ = *src++; - *dest='\0'; + while (*src && *src != '/') + { + *dest++ = *src++; + } + + *dest = '\0'; } /**************************************************************************** @@ -91,7 +99,7 @@ static void inode_namecpy(char *dest, const char *src) static FAR struct inode *inode_alloc(FAR const char *name) { int namelen = inode_namelen(name); - FAR struct inode *node = (FAR struct inode*)kmm_zalloc(FSNODE_SIZE(namelen)); + FAR struct inode *node = (FAR struct inode *)kmm_zalloc(FSNODE_SIZE(namelen)); if (node) { inode_namecpy(node->i_name, name); @@ -194,7 +202,7 @@ int inode_reserve(FAR const char *path, FAR struct inode **inode) /* Now we now where to insert the subtree */ - for (;;) + for (; ; ) { FAR struct inode *node; diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c index 0cb6f5db58..501db40282 100644 --- a/fs/mmap/fs_mmap.c +++ b/fs/mmap/fs_mmap.c @@ -133,7 +133,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags, #ifdef CONFIG_DEBUG if (prot == PROT_NONE || - (flags & (MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_DENYWRITE)) != 0) + (flags & (MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS | MAP_DENYWRITE)) != 0) { fdbg("Unsupported options, prot=%x flags=%04x\n", prot, flags); set_errno(ENOSYS); @@ -170,5 +170,5 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags, /* Return the offset address */ - return (void*)(((uint8_t*)addr) + offset); + return (FAR void *)(((FAR uint8_t *)addr) + offset); } diff --git a/fs/mmap/fs_munmap.c b/fs/mmap/fs_munmap.c index 04800d35ac..12b084d85b 100644 --- a/fs/mmap/fs_munmap.c +++ b/fs/mmap/fs_munmap.c @@ -196,7 +196,7 @@ int munmap(FAR void *start, size_t length) else { newaddr = kumm_realloc(curr->addr, sizeof(struct fs_rammap_s) + length); - DEBUGASSERT(newaddr == (FAR void*)(curr->addr)); + DEBUGASSERT(newaddr == (FAR void *)(curr->addr)); curr->length = length; } diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c index 2aaced1d0d..5f00032553 100644 --- a/fs/mmap/fs_rammap.c +++ b/fs/mmap/fs_rammap.c @@ -177,24 +177,24 @@ FAR void *rammap(int fd, size_t length, off_t offset) nread = read(fd, rdbuffer, length); if (nread < 0) { - /* Handle the special case where the read was interrupted by a - * signal. - */ + /* Handle the special case where the read was interrupted by a + * signal. + */ - err = get_errno(); - if (err != EINTR) - { - /* All other read errors are bad. errno is already set. - * (but maybe should be forced to EINVAL?). NOTE that if - * FS DEBUG is enabled, then the following fdbg() macro will - * destroy the errno value. - */ + err = get_errno(); + if (err != EINTR) + { + /* All other read errors are bad. errno is already set. + * (but maybe should be forced to EINVAL?). NOTE that if + * FS DEBUG is enabled, then the following fdbg() macro will + * destroy the errno value. + */ - fdbg("Read failed: offset=%d errno=%d\n", (int)offset, err); + fdbg("Read failed: offset=%d errno=%d\n", (int)offset, err); #ifdef CONFIG_DEBUG_FS - goto errout_with_region; + goto errout_with_region; #else - goto errout_with_errno; + goto errout_with_errno; #endif } } diff --git a/fs/mqueue/mq_close.c b/fs/mqueue/mq_close.c index 5b6db2369e..d8527e7cf3 100644 --- a/fs/mqueue/mq_close.c +++ b/fs/mqueue/mq_close.c @@ -164,25 +164,25 @@ void mq_inode_release(FAR struct inode *inode) * the inode now. */ - if (inode->i_crefs <= 0 && (inode->i_flags & FSNODEFLAG_DELETED) != 0) - { - FAR struct mqueue_inode_s *msgq = inode->u.i_mqueue; - DEBUGASSERT(msgq); + if (inode->i_crefs <= 0 && (inode->i_flags & FSNODEFLAG_DELETED) != 0) + { + FAR struct mqueue_inode_s *msgq = inode->u.i_mqueue; + DEBUGASSERT(msgq); - /* Free the message queue (and any messages left in it) */ + /* Free the message queue (and any messages left in it) */ - mq_msgqfree(msgq); - inode->u.i_mqueue = NULL; + mq_msgqfree(msgq); + inode->u.i_mqueue = NULL; - /* Release and free the inode container. If it has been properly - * unlinked, then the peer pointer should be NULL. - */ + /* Release and free the inode container. If it has been properly + * unlinked, then the peer pointer should be NULL. + */ - inode_semgive(); + inode_semgive(); - DEBUGASSERT(inode->i_peer == NULL); - inode_free(inode); - return; + DEBUGASSERT(inode->i_peer == NULL); + inode_free(inode); + return; } inode_semgive(); diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index f20e69579f..3dbb2f9f8c 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -158,7 +158,7 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...) * create a new mqueue with this name. */ - if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { errcode = EEXIST; goto errout_with_inode; @@ -186,13 +186,13 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...) goto errout_with_lock; } - /* Create the mqueue. First we have to extract the additional - * parameters from the variable argument list. - */ + /* Create the mqueue. First we have to extract the additional + * parameters from the variable argument list. + */ va_start(ap, oflags); mode = va_arg(ap, mode_t); - attr = va_arg(ap, FAR struct mq_attr*); + attr = va_arg(ap, FAR struct mq_attr *); va_end(ap); /* Create an inode in the pseudo-filesystem at this path */ @@ -211,7 +211,7 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...) * be created with a reference count of zero. */ - msgq = (FAR struct mqueue_inode_s*)mq_msgqalloc(mode, attr); + msgq = (FAR struct mqueue_inode_s *)mq_msgqalloc(mode, attr); if (!msgq) { errcode = ENOSPC; diff --git a/fs/nfs/nfs_util.c b/fs/nfs/nfs_util.c index 19e78ea650..dbe547bcd9 100644 --- a/fs/nfs/nfs_util.c +++ b/fs/nfs/nfs_util.c @@ -90,7 +90,7 @@ static inline int nfs_pathsegment(FAR const char **path, FAR char *buffer, /* Loop until the name is successfully parsed or an error occurs */ - for (;;) + for (; ; ) { /* Get the next byte from the path */ @@ -102,7 +102,7 @@ static inline int nfs_pathsegment(FAR const char **path, FAR char *buffer, { /* This logic just suppors "//" sequences in the path name */ - if (ch == '\0' || nbytes > 0 ) + if (ch == '\0' || nbytes > 0) { /* NULL terminate the parsed path segment */ @@ -433,7 +433,7 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath, * to the path is found. */ - for (;;) + for (; ; ) { /* Extract the next path segment name. */ @@ -494,7 +494,7 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath, * Desciption: * Given a path to something that may or may not be in the file system, * return the handle of the entry of the directory containing the requested -* object. + * object. * * Return Value: * Zero on success; a positive errno value on failure. @@ -527,7 +527,7 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath, /* Loop until the directory entry containing the path is found. */ - for (;;) + for (; ; ) { /* Extract the next path segment name. */ diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c index 576ee589f7..934cea664b 100644 --- a/fs/nfs/nfs_vfsops.c +++ b/fs/nfs/nfs_vfsops.c @@ -495,7 +495,7 @@ static int nfs_fileopen(FAR struct nfsmount *nmp, struct nfsnode *np, */ tmp = fxdr_unsigned(uint32_t, fattr.fa_mode); - if ((tmp & (NFSMODE_IWOTH|NFSMODE_IWGRP|NFSMODE_IWUSR)) == 0) + if ((tmp & (NFSMODE_IWOTH | NFSMODE_IWGRP | NFSMODE_IWUSR)) == 0) { fdbg("ERROR: File is read-only: %08x\n", tmp); return EACCES; @@ -504,7 +504,7 @@ static int nfs_fileopen(FAR struct nfsmount *nmp, struct nfsnode *np, /* It would be an error if we are asked to create the file exclusively */ - if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { /* Already exists -- can't create it exclusively */ @@ -528,7 +528,7 @@ static int nfs_fileopen(FAR struct nfsmount *nmp, struct nfsnode *np, * access is ignored. */ - if ((oflags & (O_TRUNC|O_WRONLY)) == (O_TRUNC|O_WRONLY)) + if ((oflags & (O_TRUNC | O_WRONLY)) == (O_TRUNC | O_WRONLY)) { /* Truncate the file to zero length. I think we can do this with * the SETATTR call by setting the length to zero. @@ -567,7 +567,7 @@ static int nfs_open(FAR struct file *filep, FAR const char *relpath, * mountpoint private data from the inode structure */ - nmp = (struct nfsmount*)filep->f_inode->i_private; + nmp = (FAR struct nfsmount *)filep->f_inode->i_private; DEBUGASSERT(nmp != NULL); /* Pre-allocate the file private data to describe the opened file. */ @@ -690,8 +690,8 @@ static int nfs_close(FAR struct file *filep) /* Recover our private data from the struct file instance */ - nmp = (struct nfsmount*) filep->f_inode->i_private; - np = (struct nfsnode*) filep->f_priv; + nmp = (FAR struct nfsmount *) filep->f_inode->i_private; + np = (FAR struct nfsnode *) filep->f_priv; DEBUGASSERT(nmp != NULL); @@ -787,8 +787,8 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen) /* Recover our private data from the struct file instance */ - nmp = (struct nfsmount*)filep->f_inode->i_private; - np = (struct nfsnode*)filep->f_priv; + nmp = (FAR struct nfsmount *)filep->f_inode->i_private; + np = (FAR struct nfsnode *)filep->f_priv; DEBUGASSERT(nmp != NULL); @@ -835,7 +835,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen) /* Initialize the request */ - ptr = (FAR uint32_t*)&nmp->nm_msgbuffer.read.read; + ptr = (FAR uint32_t *)&nmp->nm_msgbuffer.read.read; reqlen = 0; /* Copy the variable length, file handle */ @@ -963,8 +963,8 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer, /* Recover our private data from the struct file instance */ - nmp = (struct nfsmount*)filep->f_inode->i_private; - np = (struct nfsnode*)filep->f_priv; + nmp = (FAR struct nfsmount *)filep->f_inode->i_private; + np = (FAR struct nfsnode *)filep->f_priv; DEBUGASSERT(nmp != NULL); @@ -1143,8 +1143,8 @@ static int nfs_dup(FAR const struct file *oldp, FAR struct file *newp) /* Recover our private data from the struct file instance */ - nmp = (struct nfsmount*)oldp->f_inode->i_private; - np = (struct nfsnode*)oldp->f_priv; + nmp = (FAR struct nfsmount *)oldp->f_inode->i_private; + np = (FAR struct nfsnode *)oldp->f_priv; DEBUGASSERT(nmp != NULL); @@ -1305,7 +1305,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) * the dirent structure. */ - ptr = (FAR uint32_t*)&nmp->nm_msgbuffer.readdir.readdir; + ptr = (FAR uint32_t *)&nmp->nm_msgbuffer.readdir.readdir; reqlen = 0; /* Copy the variable length, directory file handle */ @@ -1421,7 +1421,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) tmp = *ptr++; length = fxdr_unsigned(uint32_t, tmp); - name = (uint8_t*)ptr; + name = (FAR uint8_t *)ptr; /* Increment the pointer past the name (allowing for padding). ptr * now points to the cookie. @@ -1702,8 +1702,9 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data, nfs_decode_args(&nprmt, argp); - /* Determine the size of a buffer that will hold one RPC data transfer. - * First, get the maximum size of a read and a write transfer */ + /* Determine the size of a buffer that will hold one RPC data transfer. + * First, get the maximum size of a read and a write transfer. + */ buflen = SIZEOF_rpc_call_write(nprmt.wsize); tmp = SIZEOF_rpc_reply_read(nprmt.rsize); @@ -1817,7 +1818,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data, error = nfs_request(nmp, NFSPROC_GETATTR, (FAR void *)&getattr, sizeof(struct FS3args), - (FAR void*)&resok, sizeof(struct rpc_reply_getattr)); + (FAR void *)&resok, sizeof(struct rpc_reply_getattr)); if (error) { fdbg("ERROR: nfs_request failed: %d\n", error); @@ -1830,7 +1831,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data, /* Mounted! */ - *handle = (void*)nmp; + *handle = (FAR void *)nmp; nfs_semgive(nmp); fvdbg("Successfully mounted\n"); @@ -2045,7 +2046,7 @@ static int nfs_statfs(FAR struct inode *mountpt, FAR struct statfs *sbp) /* Get the mountpoint private data from the inode structure */ - nmp = (struct nfsmount*)mountpt->i_private; + nmp = (FAR struct nfsmount *)mountpt->i_private; /* Check if the mount is still healthy */ @@ -2123,7 +2124,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath) /* Get the mountpoint private data from the inode structure */ - nmp = (struct nfsmount*)mountpt->i_private; + nmp = (FAR struct nfsmount *)mountpt->i_private; /* Check if the mount is still healthy */ @@ -2209,7 +2210,7 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) /* Get the mountpoint private data from the inode structure */ - nmp = (struct nfsmount*) mountpt->i_private; + nmp = (FAR struct nfsmount *) mountpt->i_private; /* Check if the mount is still healthy */ @@ -2536,7 +2537,7 @@ static int nfs_stat(struct inode *mountpt, const char *relpath, /* Get the mountpoint private data from the inode structure */ - nmp = (struct nfsmount*)mountpt->i_private; + nmp = (FAR struct nfsmount *)mountpt->i_private; DEBUGASSERT(nmp && buf); /* Check if the mount is still healthy */ @@ -2568,9 +2569,9 @@ static int nfs_stat(struct inode *mountpt, const char *relpath, * as in the NFSv3 spec. */ - mode = tmp & (NFSMODE_IXOTH|NFSMODE_IWOTH|NFSMODE_IROTH| - NFSMODE_IXGRP|NFSMODE_IWGRP|NFSMODE_IRGRP| - NFSMODE_IXUSR|NFSMODE_IWUSR|NFSMODE_IRUSR); + mode = tmp & (NFSMODE_IXOTH | NFSMODE_IWOTH | NFSMODE_IROTH | + NFSMODE_IXGRP | NFSMODE_IWGRP | NFSMODE_IRGRP | + NFSMODE_IXUSR | NFSMODE_IWUSR | NFSMODE_IRUSR); /* Handle the cases that are not the same */ diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c index 7e7c96739a..030d9bafb2 100644 --- a/fs/nfs/rpc_clnt.c +++ b/fs/nfs/rpc_clnt.c @@ -415,9 +415,9 @@ int rpcclnt_connect(struct rpcclnt *rpc) so->s_crefs = 1; rpc->rc_so = so; - /* Always set receive timeout to detect server crash and reconnect. - * Otherwise, we can get stuck in psock_receive forever. - */ + /* Always set receive timeout to detect server crash and reconnect. + * Otherwise, we can get stuck in psock_receive forever. + */ tv.tv_sec = 1; tv.tv_usec = 0; diff --git a/fs/nxffs/nxffs_blockstats.c b/fs/nxffs/nxffs_blockstats.c index 859423ca48..4ff1bd8b3a 100644 --- a/fs/nxffs/nxffs_blockstats.c +++ b/fs/nxffs/nxffs_blockstats.c @@ -125,7 +125,7 @@ int nxffs_blockstats(FAR struct nxffs_volume_s *volume, * in the NXFFS data. */ - FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s*)bptr; + FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s *)bptr; /* Increment the total count of blocks examined */ @@ -203,7 +203,7 @@ int nxffs_blockstats(FAR struct nxffs_volume_s *volume, * in the NXFFS data. */ - FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s*)volume->pack; + 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 */ diff --git a/fs/nxffs/nxffs_dump.c b/fs/nxffs/nxffs_dump.c index 19e4d4b5ce..1be0e294ac 100644 --- a/fs/nxffs/nxffs_dump.c +++ b/fs/nxffs/nxffs_dump.c @@ -149,16 +149,16 @@ static inline ssize_t nxffs_analyzeinode(FAR struct nxffs_blkinfo_s *blkinfo, return ERROR; } - spaceleft = (blkinfo->nblocks - blkinfo->block) * blkinfo->geo.blocksize; - spaceleft -= (offset + SIZEOF_NXFFS_BLOCK_HDR); - if (datlen > spaceleft) - { - /* The data length is greater than what would fit in the rest of FLASH - * (even ignoring block and data header sizes. - */ + spaceleft = (blkinfo->nblocks - blkinfo->block) * blkinfo->geo.blocksize; + spaceleft -= (offset + SIZEOF_NXFFS_BLOCK_HDR); + if (datlen > spaceleft) + { + /* The data length is greater than what would fit in the rest of FLASH + * (even ignoring block and data header sizes. + */ - return ERROR; - } + return ERROR; + } /* The name begins after the inode header. Does it begin in this block? */ diff --git a/fs/nxffs/nxffs_initialize.c b/fs/nxffs/nxffs_initialize.c index 66476f4874..745ca4560a 100644 --- a/fs/nxffs/nxffs_initialize.c +++ b/fs/nxffs/nxffs_initialize.c @@ -110,17 +110,26 @@ const struct mountpt_operations nxffs_operations = * block */ -const uint8_t g_blockmagic[NXFFS_MAGICSIZE] = { 'B', 'l', 'c', 'k' }; +const uint8_t g_blockmagic[NXFFS_MAGICSIZE] = +{ + 'B', 'l', 'c', 'k' +}; /* The magic number that appears that the beginning of each NXFFS inode */ -const uint8_t g_inodemagic[NXFFS_MAGICSIZE] = { 'I', 'n', 'o', 'd' }; +const uint8_t g_inodemagic[NXFFS_MAGICSIZE] = +{ + 'I', 'n', 'o', 'd' +}; /* The magic number that appears that the beginning of each NXFFS inode * data block. */ -const uint8_t g_datamagic[NXFFS_MAGICSIZE] = { 'D', 'a', 't', 'a' }; +const uint8_t g_datamagic[NXFFS_MAGICSIZE] = +{ + 'D', 'a', 't', 'a' +}; /* If CONFIG_NXFFS_PREALLOCATED is defined, then this is the single, pre- * allocated NXFFS volume instance. @@ -427,7 +436,7 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume) nxffs_ioseek(volume, offset); nerased = 0; - for (;;) + for (; ; ) { int ch = nxffs_getc(volume, 1); if (ch < 0) diff --git a/fs/nxffs/nxffs_inode.c b/fs/nxffs/nxffs_inode.c index a8bf821861..63ba8cbb46 100644 --- a/fs/nxffs/nxffs_inode.c +++ b/fs/nxffs/nxffs_inode.c @@ -276,7 +276,7 @@ int nxffs_nextentry(FAR struct nxffs_volume_s *volume, off_t offset, nerased = 0; nmagic = 0; - for (;;) + for (; ; ) { /* Read the next character */ @@ -401,7 +401,7 @@ int nxffs_findinode(FAR struct nxffs_volume_s *volume, FAR const char *name, * media. */ - for (;;) + for (; ; ) { /* Get the next, valid NXFFS inode entry */ diff --git a/fs/nxffs/nxffs_open.c b/fs/nxffs/nxffs_open.c index 07e115a154..f665623a06 100644 --- a/fs/nxffs/nxffs_open.c +++ b/fs/nxffs/nxffs_open.c @@ -450,7 +450,7 @@ static inline int nxffs_wropen(FAR struct nxffs_volume_s *volume, * exclusively. */ - else if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + else if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { fdbg("ERROR: File exists, can't create O_EXCL\n"); ret = -EEXIST; @@ -462,7 +462,7 @@ static inline int nxffs_wropen(FAR struct nxffs_volume_s *volume, * we will not re-create the file unless O_CREAT is also specified. */ - else if ((oflags & (O_CREAT|O_TRUNC)) == (O_CREAT|O_TRUNC)) + else if ((oflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC)) { /* Just schedule the removal the file and fall through to re-create it. * Note that the old file of the same name will not actually be removed @@ -546,7 +546,7 @@ static inline int nxffs_wropen(FAR struct nxffs_volume_s *volume, */ packed = false; - for (;;) + for (; ; ) { /* File a valid location to position the inode header. Start with the * first byte in the free FLASH region. @@ -600,7 +600,7 @@ static inline int nxffs_wropen(FAR struct nxffs_volume_s *volume, * Note that nothing is written to FLASH. */ - for (;;) + for (; ; ) { /* File a valid location to position the inode name. Start with the * first byte in the free FLASH region. @@ -853,7 +853,7 @@ static inline void nxffs_freeofile(FAR struct nxffs_volume_s *volume, */ #ifdef CONFIG_NXFFS_PREALLOCATED - if ((FAR struct nxffs_wrfile_s*)ofile != &g_wrfile) + if ((FAR struct nxffs_wrfile_s *)ofile != &g_wrfile) #endif { kmm_free(ofile); @@ -1022,7 +1022,7 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath, * file structure */ - volume = (FAR struct nxffs_volume_s*)filep->f_inode->i_private; + volume = (FAR struct nxffs_volume_s *)filep->f_inode->i_private; DEBUGASSERT(volume != NULL); #ifdef CONFIG_FILE_MODE @@ -1036,7 +1036,7 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath, * extension is supported. */ - switch (oflags & (O_WROK|O_RDOK)) + switch (oflags & (O_WROK | O_RDOK)) { case 0: default: @@ -1051,7 +1051,7 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath, ret = nxffs_rdopen(volume, relpath, &ofile); break; - case O_WROK|O_RDOK: + case O_WROK | O_RDOK: fdbg("ERROR: O_RDWR is not supported\n"); return -ENOSYS; } @@ -1092,7 +1092,7 @@ int nxffs_dup(FAR const struct file *oldp, FAR struct file *newp) * file structure */ - volume = (FAR struct nxffs_volume_s*)oldp->f_inode->i_private; + volume = (FAR struct nxffs_volume_s *)oldp->f_inode->i_private; DEBUGASSERT(volume != NULL); #endif diff --git a/fs/nxffs/nxffs_pack.c b/fs/nxffs/nxffs_pack.c index 8706e8009a..14c9e8d8f1 100644 --- a/fs/nxffs/nxffs_pack.c +++ b/fs/nxffs/nxffs_pack.c @@ -286,7 +286,7 @@ static inline int nxffs_startpos(FAR struct nxffs_volume_s *volume, * compacting. */ - for (;;) + for (; ; ) { /* Is there wasted space between the offset where the we could have * valid data and the offset to the beginning of the first valid @@ -358,12 +358,12 @@ static inline int nxffs_startpos(FAR struct nxffs_volume_s *volume, ret = nxffs_validblock(volume, &volume->ioblock); if (ret < 0) { - /* No valid blocks? Then there is nothing we can do. Return - * the end-of-flash indication. - */ + /* No valid blocks? Then there is nothing we can do. Return + * the end-of-flash indication. + */ - *froffset = volume->froffset; - return -ENOSPC; + *froffset = volume->froffset; + return -ENOSPC; } volume->iooffset = SIZEOF_NXFFS_BLOCK_HDR; @@ -933,7 +933,7 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, * block is full, or (3) an error occurs. */ - for (;;) + for (; ; ) { /* Transfer data from the source buffer to the destination buffer */ @@ -1186,39 +1186,39 @@ static inline int nxffs_packwriter(FAR struct nxffs_volume_s *volume, * block is full, or (3) an error occurs. */ - for (;;) + for (; ; ) { - /* Transfer data from the source buffer to the destination buffer */ + /* Transfer data from the source buffer to the destination buffer */ - nxffs_packtransfer(volume, pack); + nxffs_packtransfer(volume, pack); - /* Now, either the (1) src block has been fully transferred, (2) all - * of the source data has been transferred, or (3) the destination - * block is full, .. or all three. - * - * Check if all of the bytes in the source inode have been transferred. - */ + /* Now, either the (1) src block has been fully transferred, (2) all + * of the source data has been transferred, or (3) the destination + * block is full, .. or all three. + * + * Check if all of the bytes in the source inode have been transferred. + */ - if (pack->src.fpos >= pack->src.entry.datlen) - { - /* Write the final destination data block header and inode - * headers. - */ + if (pack->src.fpos >= pack->src.entry.datlen) + { + /* Write the final destination data block header and inode + * headers. + */ - nxffs_wrdathdr(volume, pack); + nxffs_wrdathdr(volume, pack); - /* Set the new offsets in the open file instance. */ + /* Set the new offsets in the open file instance. */ - wrfile->ofile.entry.hoffset = pack->dest.entry.hoffset; - wrfile->ofile.entry.noffset = pack->dest.entry.noffset; - wrfile->ofile.entry.doffset = pack->dest.entry.doffset; + wrfile->ofile.entry.hoffset = pack->dest.entry.hoffset; + wrfile->ofile.entry.noffset = pack->dest.entry.noffset; + wrfile->ofile.entry.doffset = pack->dest.entry.doffset; - /* Return an end-of-flash error to indicate that all of the write - * data has been transferred. - */ + /* Return an end-of-flash error to indicate that all of the write + * data has been transferred. + */ - return -ENOSPC; - } + return -ENOSPC; + } /* Not at the end of the source data stream. Check if we are at the * end of the current source data block. @@ -1312,7 +1312,7 @@ int nxffs_pack(FAR struct nxffs_volume_s *volume) /* No, there is no write in progress. We just have an empty flash * full of deleted files. In this case, the media needs to be re- * formatted. - */ + */ ret = nxffs_reformat(volume); if (ret == OK) @@ -1359,19 +1359,19 @@ int nxffs_pack(FAR struct nxffs_volume_s *volume) if (iooffset + CONFIG_NXFFS_TAILTHRESHOLD < volume->froffset) { - /* Setting 'packed' to true will supress normal inode packing - * operation. - */ + /* Setting 'packed' to true will supress normal inode packing + * operation. + */ - packed = true; + packed = true; - /* Writing is performed at the end of the free FLASH region. - * If we are not packing files, we could still need to pack - * the partially written file at the end of FLASH. - */ + /* Writing is performed at the end of the free FLASH region. + * If we are not packing files, we could still need to pack + * the partially written file at the end of FLASH. + */ - wrfile = nxffs_setupwriter(volume, &pack); - } + wrfile = nxffs_setupwriter(volume, &pack); + } /* Otherwise return OK.. meaning that there is nothing more we can * do to recover FLASH space. @@ -1422,7 +1422,7 @@ start_pack: ret = MTD_BREAD(volume->mtd, pack.block0, volume->blkper, volume->pack); if (ret < 0) { - fdbg("ERROR: Failed to read erase block %d: %d\n", eblock,-ret); + fdbg("ERROR: Failed to read erase block %d: %d\n", eblock, -ret); goto errout_with_pack; } @@ -1462,120 +1462,120 @@ start_pack: i < volume->blkper; i++, block++, pack.iobuffer += volume->geo.blocksize) { - /* The first time here, the ioblock may point to an offset into - * the erase block. We just need to skip over those cases. - */ + /* The first time here, the ioblock may point to an offset into + * the erase block. We just need to skip over those cases. + */ - if (block >= pack.ioblock) - { - /* Set the I/O position. Note on the first time we get - * pack.iooffset will hold the offset in the first I/O block - * to the first inode header. After that, it will always - * refer to the first byte after the block header. - */ + if (block >= pack.ioblock) + { + /* Set the I/O position. Note on the first time we get + * pack.iooffset will hold the offset in the first I/O block + * to the first inode header. After that, it will always + * refer to the first byte after the block header. + */ - pack.ioblock = block; + pack.ioblock = block; - /* If this is not a valid block or if we have already - * finished packing the valid inode entries, then just fall - * through, reset the FLASH memory to the erase state, and - * write the reset values to FLASH. (The first block that - * we want to process will always be valid -- we have - * already verified that). - */ + /* If this is not a valid block or if we have already + * finished packing the valid inode entries, then just fall + * through, reset the FLASH memory to the erase state, and + * write the reset values to FLASH. (The first block that + * we want to process will always be valid -- we have + * already verified that). + */ - if (nxffs_packvalid(&pack)) - { - /* Have we finished packing inodes? */ + if (nxffs_packvalid(&pack)) + { + /* Have we finished packing inodes? */ - if (!packed) - { - DEBUGASSERT(wrfile == NULL); + if (!packed) + { + DEBUGASSERT(wrfile == NULL); - /* Pack inode data into this block */ + /* Pack inode data into this block */ - ret = nxffs_packblock(volume, &pack); - if (ret < 0) - { - /* The error -ENOSPC is a special value that simply - * means that there is nothing further to be packed. - */ + ret = nxffs_packblock(volume, &pack); + if (ret < 0) + { + /* The error -ENOSPC is a special value that simply + * means that there is nothing further to be packed. + */ - if (ret == -ENOSPC) - { - packed = true; + if (ret == -ENOSPC) + { + packed = true; - /* Writing is performed at the end of the free - * FLASH region and this implemenation is restricted - * to a single writer. The new inode is not - * written to FLASH until the writer is closed - * and so will not be found by nxffs_packblock(). - */ + /* Writing is performed at the end of the free + * FLASH region and this implemenation is restricted + * to a single writer. The new inode is not + * written to FLASH until the writer is closed + * and so will not be found by nxffs_packblock(). + */ - wrfile = nxffs_setupwriter(volume, &pack); - } - else - { - /* Otherwise, something really bad happened */ + wrfile = nxffs_setupwriter(volume, &pack); + } + else + { + /* Otherwise, something really bad happened */ - fdbg("ERROR: Failed to pack into block %d: %d\n", - block, ret); - goto errout_with_pack; - } - } - } + fdbg("ERROR: Failed to pack into block %d: %d\n", + block, ret); + goto errout_with_pack; + } + } + } - /* If all of the "normal" inodes have been packed, then check if - * we need to pack the current, in-progress write operation. - */ + /* If all of the "normal" inodes have been packed, then check if + * we need to pack the current, in-progress write operation. + */ - if (wrfile) - { - DEBUGASSERT(packed == true); + if (wrfile) + { + DEBUGASSERT(packed == true); - /* Pack write data into this block */ + /* Pack write data into this block */ - ret = nxffs_packwriter(volume, &pack, wrfile); - if (ret < 0) - { - /* The error -ENOSPC is a special value that simply - * means that there is nothing further to be packed. - */ + ret = nxffs_packwriter(volume, &pack, wrfile); + if (ret < 0) + { + /* The error -ENOSPC is a special value that simply + * means that there is nothing further to be packed. + */ - if (ret == -ENOSPC) - { - wrfile = NULL; - } - else - { - /* Otherwise, something really bad happened */ + if (ret == -ENOSPC) + { + wrfile = NULL; + } + else + { + /* Otherwise, something really bad happened */ - fdbg("ERROR: Failed to pack into block %d: %d\n", - block, ret); - goto errout_with_pack; - } - } - } - } + fdbg("ERROR: Failed to pack into block %d: %d\n", + block, ret); + goto errout_with_pack; + } + } + } + } - /* Set any unused portion at the end of the block to the - * erased state. - */ + /* Set any unused portion at the end of the block to the + * erased state. + */ - if (pack.iooffset < volume->geo.blocksize) - { - memset(&pack.iobuffer[pack.iooffset], - CONFIG_NXFFS_ERASEDSTATE, - volume->geo.blocksize - pack.iooffset); - } + if (pack.iooffset < volume->geo.blocksize) + { + memset(&pack.iobuffer[pack.iooffset], + CONFIG_NXFFS_ERASEDSTATE, + volume->geo.blocksize - pack.iooffset); + } - /* Next time through the loop, pack.iooffset will point to the - * first byte after the block header. - */ + /* Next time through the loop, pack.iooffset will point to the + * first byte after the block header. + */ - pack.iooffset = SIZEOF_NXFFS_BLOCK_HDR; - } - } + pack.iooffset = SIZEOF_NXFFS_BLOCK_HDR; + } + } /* We now have an in-memory image of how we want this erase block to * appear. Now it is safe to erase the block. diff --git a/fs/nxffs/nxffs_read.c b/fs/nxffs/nxffs_read.c index 934a640bf6..6bd09374f9 100644 --- a/fs/nxffs/nxffs_read.c +++ b/fs/nxffs/nxffs_read.c @@ -294,7 +294,7 @@ int nxffs_nextblock(FAR struct nxffs_volume_s *volume, off_t offset, nerased = 0; nmagic = 0; - for (;;) + for (; ; ) { /* Read the next character */ diff --git a/fs/nxffs/nxffs_reformat.c b/fs/nxffs/nxffs_reformat.c index b969a398b3..ba151f4cc9 100644 --- a/fs/nxffs/nxffs_reformat.c +++ b/fs/nxffs/nxffs_reformat.c @@ -190,7 +190,7 @@ static int nxffs_badblocks(FAR struct nxffs_volume_s *volume) i++, block++, blkptr += volume->geo.blocksize) #endif { - FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s*)blkptr; + FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s *)blkptr; /* Assume that this is a good block until we learn otherwise */ @@ -330,7 +330,7 @@ int nxffs_reformat(FAR struct nxffs_volume_s *volume) void nxffs_blkinit(FAR struct nxffs_volume_s *volume, FAR uint8_t *blkptr, uint8_t state) { - FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s*)blkptr; + FAR struct nxffs_block_s *blkhdr = (FAR struct nxffs_block_s *)blkptr; memset(blkptr, CONFIG_NXFFS_ERASEDSTATE, volume->geo.blocksize); memcpy(blkhdr->magic, g_blockmagic, NXFFS_MAGICSIZE); diff --git a/fs/nxffs/nxffs_stat.c b/fs/nxffs/nxffs_stat.c index 9f45b5a4b1..f4a16a2117 100644 --- a/fs/nxffs/nxffs_stat.c +++ b/fs/nxffs/nxffs_stat.c @@ -166,7 +166,7 @@ int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath, } buf->st_blocks = entry.datlen / (volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR); - buf->st_mode = S_IFREG|S_IXOTH|S_IXGRP|S_IXUSR; + buf->st_mode = S_IFREG | S_IXOTH | S_IXGRP | S_IXUSR; buf->st_size = entry.datlen; buf->st_atime = entry.utc; buf->st_mtime = entry.utc; @@ -180,7 +180,8 @@ int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath, { /* It's a read/execute-only directory name */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IXOTH|S_IXGRP|S_IXUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR | S_IXOTH | + S_IXGRP | S_IXUSR; } ret = OK; diff --git a/fs/nxffs/nxffs_write.c b/fs/nxffs/nxffs_write.c index 7f081b92d8..561fb58bea 100644 --- a/fs/nxffs/nxffs_write.c +++ b/fs/nxffs/nxffs_write.c @@ -227,7 +227,7 @@ static inline int nxffs_wralloc(FAR struct nxffs_volume_s *volume, */ packed = false; - for (;;) + for (; ; ) { size_t mindata = MIN(NXFFS_MINDATA, size); diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index d23ea195bd..5b6786b2e6 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -647,33 +647,33 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) /* Test if we skipped this entry */ if (name != NULL) - { - /* This entry is okay to report. Test if it has a duplicate - * first level name as the one we just reported. This could - * happen in the event of procfs_entry_s such as: - * - * fs/smartfs - * fs/nfs - * fs/nxffs - */ + { + /* This entry is okay to report. Test if it has a duplicate + * first level name as the one we just reported. This could + * happen in the event of procfs_entry_s such as: + * + * fs/smartfs + * fs/nfs + * fs/nxffs + */ - name = g_procfsentries[index - priv->nentries].pathpattern; - if (!level0->lastlen || (strncmp(name, level0->lastread, + name = g_procfsentries[index - priv->nentries].pathpattern; + if (!level0->lastlen || (strncmp(name, level0->lastread, level0->lastlen) != 0)) - { - /* Not a duplicate, return the first segment of this - * entry - */ + { + /* Not a duplicate, return the first segment of this + * entry + */ - break; - } - else - { - /* Skip this entry ... duplicate 1st level name found */ + break; + } + else + { + /* Skip this entry ... duplicate 1st level name found */ - index++; - } - } + index++; + } + } } /* Test if we are at the end of the directory */ @@ -915,7 +915,7 @@ static int procfs_stat(struct inode *mountpt, const char *relpath, /* 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; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; ret = OK; } else @@ -945,7 +945,7 @@ static int procfs_stat(struct inode *mountpt, const char *relpath, { /* It's an internal subdirectory */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; ret = OK; break; } diff --git a/fs/procfs/fs_procfscpuload.c b/fs/procfs/fs_procfscpuload.c index f60789a768..fd94c91870 100644 --- a/fs/procfs/fs_procfscpuload.c +++ b/fs/procfs/fs_procfscpuload.c @@ -337,7 +337,7 @@ static int cpuload_stat(const char *relpath, struct stat *buf) /* "cpuload" is the name for a read-only file */ - buf->st_mode = S_IFREG|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; buf->st_size = 0; buf->st_blksize = 0; buf->st_blocks = 0; diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 80ea40583c..62284797df 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -1455,7 +1455,7 @@ static int proc_stat(const char *relpath, struct stat *buf) { /* Yes ... It's a read-only directory */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; } /* Verify that the process ID is followed by valid path segment delimiter */ @@ -1492,11 +1492,11 @@ static int proc_stat(const char *relpath, struct stat *buf) if (node->dtype == DTYPE_FILE) { - buf->st_mode = S_IFREG|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; } else { - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; } } diff --git a/fs/procfs/fs_procfsuptime.c b/fs/procfs/fs_procfsuptime.c index 7d924087c8..c5f8c719a5 100644 --- a/fs/procfs/fs_procfsuptime.c +++ b/fs/procfs/fs_procfsuptime.c @@ -351,7 +351,7 @@ static int uptime_dup(FAR const struct file *oldp, FAR struct file *newp) * ****************************************************************************/ -static int uptime_stat(const char *relpath, struct stat *buf) +static int uptime_stat(FAR const char *relpath, FAR struct stat *buf) { /* "uptime" is the only acceptable value for the relpath */ @@ -363,7 +363,7 @@ static int uptime_stat(const char *relpath, struct stat *buf) /* "uptime" is the name for a read-only file */ - buf->st_mode = S_IFREG|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; buf->st_size = 0; buf->st_blksize = 0; buf->st_blocks = 0; diff --git a/fs/procfs/fs_skeleton.c b/fs/procfs/fs_skeleton.c index 0dd573f562..99ba5b4f18 100644 --- a/fs/procfs/fs_skeleton.c +++ b/fs/procfs/fs_skeleton.c @@ -441,7 +441,7 @@ static int skel_stat(const char *relpath, struct stat *buf) * or a directory and set it's permissions. */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; ret = OK; /* File/directory size, access block size */ diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c index 8198b2b657..00f3f92886 100644 --- a/fs/romfs/fs_romfs.c +++ b/fs/romfs/fs_romfs.c @@ -167,7 +167,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath, * structure */ - rm = (FAR struct romfs_mountpt_s*)filep->f_inode->i_private; + rm = (FAR struct romfs_mountpt_s *)filep->f_inode->i_private; DEBUGASSERT(rm != NULL); @@ -344,7 +344,7 @@ static ssize_t romfs_read(FAR struct file *filep, FAR char *buffer, uint32_t offset; size_t bytesleft; off_t sector; - FAR uint8_t *userbuffer = (FAR uint8_t*)buffer; + FAR uint8_t *userbuffer = (FAR uint8_t *)buffer; int sectorndx; int ret; @@ -586,7 +586,7 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * the file. */ - *ppv = (void*)(rm->rm_xipbase + rf->rf_startoffset); + *ppv = (FAR void *)(rm->rm_xipbase + rf->rf_startoffset); return OK; } @@ -617,7 +617,7 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp) * structure */ - rm = (FAR struct romfs_mountpt_s*)newp->f_inode->i_private; + rm = (FAR struct romfs_mountpt_s *)newp->f_inode->i_private; DEBUGASSERT(rm != NULL); /* Check if the mount is still healthy */ @@ -789,7 +789,7 @@ static int romfs_readdir(FAR struct inode *mountpt, /* Loop, skipping over unsupported items in the file system */ - for (;;) + for (; ; ) { /* Have we reached the end of the directory */ @@ -955,7 +955,7 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data, /* Mounted! */ - *handle = (void*)rm; + *handle = (FAR void *)rm; romfs_semgive(rm); return OK; @@ -982,7 +982,7 @@ errout_with_sem: static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver, unsigned int flags) { - FAR struct romfs_mountpt_s *rm = (FAR struct romfs_mountpt_s*)handle; + FAR struct romfs_mountpt_s *rm = (FAR struct romfs_mountpt_s *)handle; int ret; fvdbg("Entry\n"); @@ -1159,20 +1159,20 @@ static int romfs_stat(FAR struct inode *mountpt, FAR const char *relpath, { /* It's a read-only directory name */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; if (IS_EXECUTABLE(dirinfo.rd_next)) { - buf->st_mode |= S_IXOTH|S_IXGRP|S_IXUSR; + buf->st_mode |= S_IXOTH | S_IXGRP | S_IXUSR; } } else if (IS_FILE(dirinfo.rd_next)) { /* It's a read-only file name */ - buf->st_mode = S_IFREG|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; if (IS_EXECUTABLE(dirinfo.rd_next)) { - buf->st_mode |= S_IXOTH|S_IXGRP|S_IXUSR; + buf->st_mode |= S_IXOTH | S_IXGRP | S_IXUSR; } } else diff --git a/fs/romfs/fs_romfsutil.c b/fs/romfs/fs_romfsutil.c index 65528d1378..7269bf14bc 100644 --- a/fs/romfs/fs_romfsutil.c +++ b/fs/romfs/fs_romfsutil.c @@ -108,7 +108,7 @@ static uint32_t romfs_devread32(struct romfs_mountpt_s *rm, int ndx) { /* Extract the value */ - uint32_t value = *(uint32_t*)&rm->rm_buffer[ndx]; + uint32_t value = *(FAR uint32_t *)&rm->rm_buffer[ndx]; /* Value is begin endian -- return the native host endian-ness. */ #ifdef CONFIG_ENDIAN_BIG @@ -228,7 +228,7 @@ int16_t romfs_devcacheread(struct romfs_mountpt_s *rm, uint32_t offset) } else { - /* In non-XIP mode, we will have to read the new sector.*/ + /* In non-XIP mode, we will have to read the new sector. */ ret = romfs_hwread(rm, rm->rm_buffer, sector, 1); if (ret < 0) @@ -477,7 +477,7 @@ int romfs_filecacheread(struct romfs_mountpt_s *rm, struct romfs_file_s *rf, } else { - /* In non-XIP mode, we will have to read the new sector.*/ + /* In non-XIP mode, we will have to read the new sector. */ fvdbg("Calling romfs_hwread\n"); ret = romfs_hwread(rm, rf->rf_buffer, sector, 1); @@ -560,7 +560,7 @@ int romfs_hwconfigure(struct romfs_mountpt_s *rm) /* Allocate the device cache buffer for normal sector accesses */ - rm->rm_buffer = (uint8_t*)kmm_malloc(rm->rm_hwsectorsize); + rm->rm_buffer = (FAR uint8_t *)kmm_malloc(rm->rm_hwsectorsize); if (!rm->rm_buffer) { return -ENOMEM; @@ -608,7 +608,7 @@ int romfs_fsconfigure(struct romfs_mountpt_s *rm) /* The root directory entry begins right after the header */ - name = (const char*)&rm->rm_buffer[ROMFS_VHDR_VOLNAME]; + name = (FAR const char *)&rm->rm_buffer[ROMFS_VHDR_VOLNAME]; rm->rm_rootoffset = ROMFS_ALIGNUP(ROMFS_VHDR_VOLNAME + strlen(name) + 1); /* and return success */ @@ -648,7 +648,7 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf) /* Create a file buffer to support partial sector accesses */ - rf->rf_buffer = (uint8_t*)kmm_malloc(rm->rm_hwsectorsize); + rf->rf_buffer = (FAR uint8_t *)kmm_malloc(rm->rm_hwsectorsize); if (!rf->rf_buffer) { return -ENOMEM; @@ -738,7 +738,7 @@ int romfs_finddirentry(struct romfs_mountpt_s *rm, entryname = path; terminator = NULL; - for (;;) + for (; ; ) { /* Find the start of the next path component */ @@ -876,7 +876,7 @@ int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset, */ offset += ROMFS_FHDR_NAME; - for (namelen = 0, done = false; namelen < NAME_MAX && !done;) + for (namelen = 0, done = false; namelen < NAME_MAX && !done; ) { /* Read the sector into memory */ @@ -892,7 +892,7 @@ int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset, { /* Yes.. then this chunk is less than 16 */ - chunklen = strlen((char*)&rm->rm_buffer[ndx]); + chunklen = strlen((FAR char *)&rm->rm_buffer[ndx]); done = true; } else @@ -948,7 +948,7 @@ int romfs_datastart(struct romfs_mountpt_s *rm, uint32_t offset, /* Loop until the header size is obtained. */ offset += ROMFS_FHDR_NAME; - for (;;) + for (; ; ) { /* Read the sector into memory */ diff --git a/fs/semaphore/sem_close.c b/fs/semaphore/sem_close.c index 3e9dfffa5c..97d2bf5886 100644 --- a/fs/semaphore/sem_close.c +++ b/fs/semaphore/sem_close.c @@ -127,23 +127,23 @@ int sem_close(FAR sem_t *sem) * now. */ - if (inode->i_crefs <= 0 && (inode->i_flags & FSNODEFLAG_DELETED) != 0) - { - /* Destroy the semaphore and free the container */ + if (inode->i_crefs <= 0 && (inode->i_flags & FSNODEFLAG_DELETED) != 0) + { + /* Destroy the semaphore and free the container */ - sem_destroy(&nsem->ns_sem); - group_free(NULL, nsem); + sem_destroy(&nsem->ns_sem); + group_free(NULL, nsem); - /* Release and free the inode container. If it has been properly - * unlinked, then the peer pointer should be NULL. - */ + /* Release and free the inode container. If it has been properly + * unlinked, then the peer pointer should be NULL. + */ - inode_semgive(); + inode_semgive(); - DEBUGASSERT(inode->i_peer == NULL); - inode_free(inode); - return OK; - } + DEBUGASSERT(inode->i_peer == NULL); + inode_free(inode); + return OK; + } inode_semgive(); return OK; diff --git a/fs/semaphore/sem_open.c b/fs/semaphore/sem_open.c index e5e46d9ba6..4bae07352c 100644 --- a/fs/semaphore/sem_open.c +++ b/fs/semaphore/sem_open.c @@ -125,7 +125,7 @@ FAR sem_t *sem_open (FAR const char *name, int oflags, ...) FAR const char *relpath = NULL; mode_t mode; FAR struct nsem_inode_s *nsem; - FAR sem_t *sem = (FAR sem_t*)ERROR; + FAR sem_t *sem = (FAR sem_t *)ERROR; char fullpath[MAX_SEMPATH]; unsigned value; int errcode; @@ -168,7 +168,7 @@ FAR sem_t *sem_open (FAR const char *name, int oflags, ...) * create a new semaphore with this name. */ - if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { errcode = EEXIST; goto errout_with_inode; @@ -195,10 +195,10 @@ FAR sem_t *sem_open (FAR const char *name, int oflags, ...) goto errout_with_lock; } - /* Create the semaphore. First we have to extract the additional - * parameters from the variable argument list. - * REVISIT: Mode parameter is not currently used. - */ + /* Create the semaphore. First we have to extract the additional + * parameters from the variable argument list. + * REVISIT: Mode parameter is not currently used. + */ va_start(ap, oflags); mode = va_arg(ap, mode_t); diff --git a/fs/smartfs/smartfs_mksmartfs.c b/fs/smartfs/smartfs_mksmartfs.c index 620a6096fb..076915e169 100644 --- a/fs/smartfs/smartfs_mksmartfs.c +++ b/fs/smartfs/smartfs_mksmartfs.c @@ -93,7 +93,7 @@ int mksmartfs(FAR const char *pathname, uint8_t nrootdirs) int mksmartfs(FAR const char *pathname) #endif { - struct inode* inode; + FAR struct inode *inode; struct smart_format_s fmt; int ret; int x; diff --git a/fs/smartfs/smartfs_procfs.c b/fs/smartfs/smartfs_procfs.c index 960f37893a..c0f60c13e6 100644 --- a/fs/smartfs/smartfs_procfs.c +++ b/fs/smartfs/smartfs_procfs.c @@ -88,7 +88,7 @@ struct smartfs_level1_s * open / read / stat, etc. */ - struct smartfs_mountpt_s* mount; + FAR struct smartfs_mountpt_s *mount; uint8_t direntry; }; @@ -216,7 +216,7 @@ static int smartfs_find_dirref(FAR const char *relpath, FAR struct smartfs_level1_s *level1) { int ret = -ENOENT; - FAR struct smartfs_mountpt_s* mount; + FAR struct smartfs_mountpt_s *mount; uint16_t x; FAR char * str; @@ -715,7 +715,7 @@ static int smartfs_stat(const char *relpath, struct stat *buf) ret = smartfs_find_dirref(relpath, &level1); - buf->st_mode = S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IROTH | S_IRGRP | S_IRUSR; if (ret == OK) { if (level1.base.level < 3) @@ -982,7 +982,6 @@ static size_t smartfs_erasemap_read(FAR struct file *filep, FAR char *buffer, copylen = 0; for (y = 0; y < rows; y++) { - //for (x = 0; x < 128; x++) for (x = 0; x < cols; x++) { /* Copy data to the buffer */ diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c index 55228b2a5d..fffba254b7 100644 --- a/fs/smartfs/smartfs_smart.c +++ b/fs/smartfs/smartfs_smart.c @@ -236,7 +236,7 @@ static int smartfs_open(FAR struct file *filep, const char *relpath, /* It would be an error if we are asked to create it exclusively */ - if ((oflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { /* Already exists -- can't create it exclusively */ @@ -435,7 +435,7 @@ static int smartfs_close(FAR struct file *filep) /* Now free the pointer */ - filep->f_priv = NULL;; + filep->f_priv = NULL; if (sf->entry.name != NULL) { /* Free the space for the name too */ @@ -1532,7 +1532,7 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data, return ret; } - *handle = (void*)fs; + *handle = (FAR void *)fs; smartfs_semgive(fs); return OK; } @@ -1548,7 +1548,7 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data, static int smartfs_unbind(FAR void *handle, FAR struct inode **blkdriver, unsigned int flags) { - struct smartfs_mountpt_s *fs = (struct smartfs_mountpt_s*)handle; + FAR struct smartfs_mountpt_s *fs = (FAR struct smartfs_mountpt_s *)handle; int ret; if (!fs) @@ -2105,7 +2105,8 @@ static int smartfs_stat(struct inode *mountpt, const char *relpath, struct stat { /* It's directory name of the mount point */ - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR|S_IWOTH|S_IWGRP|S_IWUSR; + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR | S_IWOTH | + S_IWGRP | S_IWUSR; ret = OK; goto errout_with_semaphore; } diff --git a/fs/smartfs/smartfs_utils.c b/fs/smartfs/smartfs_utils.c index db0de34fa0..58dcde8e6b 100644 --- a/fs/smartfs/smartfs_utils.c +++ b/fs/smartfs/smartfs_utils.c @@ -74,7 +74,7 @@ #if defined(CONFIG_SMARTFS_MULTI_ROOT_DIRS) || \ (defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS)) -static struct smartfs_mountpt_s* g_mounthead = NULL; +static struct smartfs_mountpt_s *g_mounthead = NULL; #endif /**************************************************************************** @@ -840,11 +840,11 @@ errout: * ****************************************************************************/ -int smartfs_createentry(struct smartfs_mountpt_s *fs, - uint16_t parentdirsector, const char* filename, - uint16_t type, - mode_t mode, struct smartfs_entry_s *direntry, - uint16_t sectorno, FAR struct smartfs_ofile_s *sf) +int smartfs_createentry(FAR struct smartfs_mountpt_s *fs, + uint16_t parentdirsector, FAR const char *filename, + uint16_t type, mode_t mode, + FAR struct smartfs_entry_s *direntry, + uint16_t sectorno, FAR struct smartfs_ofile_s *sf) { struct smart_read_write_s readwrite; int ret; @@ -908,9 +908,9 @@ int smartfs_createentry(struct smartfs_mountpt_s *fs, if ((entry->flags == SMARTFS_ERASEDSTATE_16BIT) || ((entry->flags & #endif - (SMARTFS_DIRENT_EMPTY | SMARTFS_DIRENT_ACTIVE) ) == + (SMARTFS_DIRENT_EMPTY | SMARTFS_DIRENT_ACTIVE)) == (~SMARTFS_ERASEDSTATE_16BIT & - (SMARTFS_DIRENT_EMPTY | SMARTFS_DIRENT_ACTIVE) ))) + (SMARTFS_DIRENT_EMPTY | SMARTFS_DIRENT_ACTIVE)))) { /* We found an empty entry. Use it. */ @@ -1034,7 +1034,8 @@ int smartfs_createentry(struct smartfs_mountpt_s *fs, ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long) &readwrite); if (ret < 0) { - fdbg("Error %d setting new sector type for sector %d\n",ret, nextsector); + fdbg("Error %d setting new sector type for sector %d\n", + ret, nextsector); goto errout; } } @@ -1122,7 +1123,7 @@ int smartfs_deleteentry(struct smartfs_mountpt_s *fs, struct smart_read_write_s readwrite; /* Okay, delete the file. Loop through each sector and release them - + * * TODO: We really should walk the list backward to avoid lost * sectors in the event we lose power. However this requires * allocating a buffer to build the sector list since we don't @@ -1493,7 +1494,7 @@ int smartfs_truncatefile(struct smartfs_mountpt_s *fs, } /* Now deal with the first sector in the event we are using a sector buffer - like we would be if CRC is enabled. + * like we would be if CRC is enabled. */ #ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER @@ -1531,7 +1532,7 @@ errout: ****************************************************************************/ #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS) -struct smartfs_mountpt_s* smartfs_get_first_mount(void) +FAR struct smartfs_mountpt_s *smartfs_get_first_mount(void) { return g_mounthead; } diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c index f57d3dd2a7..491d71f74a 100644 --- a/fs/unionfs/fs_unionfs.c +++ b/fs/unionfs/fs_unionfs.c @@ -2085,7 +2085,8 @@ static int unionfs_unlink(FAR struct inode *mountpt, } /* Check if some exists at this path on file system 1. This might be - * a file or a directory*/ + * a file or a directory + */ um = &ui->ui_fs[0]; ret = unionfs_trystat(um->um_node, relpath, um->um_prefix, &buf); @@ -2612,7 +2613,6 @@ int unionfs_mount(FAR const char *fspath1, FAR const char *prefix1, errout_with_semaphore: inode_semgive(); -//errout_with_prefix2: if (ui->ui_fs[1].um_prefix != NULL) { kmm_free(ui->ui_fs[1].um_prefix); diff --git a/fs/vfs/fs_dup.c b/fs/vfs/fs_dup.c index 8e8edb86fa..03b8b751ab 100644 --- a/fs/vfs/fs_dup.c +++ b/fs/vfs/fs_dup.c @@ -77,7 +77,8 @@ int dup(int fd) if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) { /* Its a valid file descriptor.. dup the file descriptor using any - * other file descriptor*/ + * other file descriptor + */ ret = fs_dupfd(fd, 0); } diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index ed44e47e21..ae903970fe 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -107,7 +107,7 @@ int open(const char *path, int oflags, ...) /* If the file is opened for creation, then get the mode bits */ - if ((oflags & (O_WRONLY|O_CREAT)) != 0) + if ((oflags & (O_WRONLY | O_CREAT)) != 0) { va_list ap; va_start(ap, oflags); diff --git a/fs/vfs/fs_read.c b/fs/vfs/fs_read.c index c5cdc701e6..f1d6097236 100644 --- a/fs/vfs/fs_read.c +++ b/fs/vfs/fs_read.c @@ -101,7 +101,7 @@ ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes) * signature and position in the operations vtable. */ - ret = (int)inode->u.i_ops->read(filep, (char*)buf, (size_t)nbytes); + ret = (int)inode->u.i_ops->read(filep, (FAR char *)buf, (size_t)nbytes); } /* If an error occurred, set errno and return -1 (ERROR) */ diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index 60151232f2..d71d8e28a1 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -238,7 +238,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, if (readfds) { - if (pollset[ndx].revents & (POLLIN|POLLHUP)) + if (pollset[ndx].revents & (POLLIN | POLLHUP)) { FD_SET(pollset[ndx].fd, readfds); ret++; diff --git a/fs/vfs/fs_stat.c b/fs/vfs/fs_stat.c index 1bd9d05d8e..a96cf3be71 100644 --- a/fs/vfs/fs_stat.c +++ b/fs/vfs/fs_stat.c @@ -58,7 +58,7 @@ static inline int statpseudo(FAR struct inode *inode, FAR struct stat *buf) { /* Most of the stat entries just do not apply */ - memset(buf, 0, sizeof(struct stat) ); + memset(buf, 0, sizeof(struct stat)); if (INODE_IS_SPECIAL(inode)) { @@ -90,12 +90,12 @@ static inline int statpseudo(FAR struct inode *inode, FAR struct stat *buf) { if (inode->u.i_ops->read) { - buf->st_mode = S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode = S_IROTH | S_IRGRP | S_IRUSR; } if (inode->u.i_ops->write) { - buf->st_mode |= S_IWOTH|S_IWGRP|S_IWUSR; + buf->st_mode |= S_IWOTH | S_IWGRP | S_IWUSR; } if (INODE_IS_MOUNTPT(inode)) @@ -123,7 +123,7 @@ static inline int statpseudo(FAR struct inode *inode, FAR struct stat *buf) * write-able. */ - buf->st_mode |= S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + buf->st_mode |= S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; } return OK; @@ -137,8 +137,8 @@ static inline int statroot(FAR struct stat *buf) { /* There is no inode associated with the fake root directory */ - memset(buf, 0, sizeof(struct stat) ); - buf->st_mode = S_IFDIR|S_IROTH|S_IRGRP|S_IRUSR; + memset(buf, 0, sizeof(struct stat)); + buf->st_mode = S_IFDIR | S_IROTH | S_IRGRP | S_IRUSR; return OK; }