Skip to content

Commit 4ebcc13

Browse files
xiaoxiang781216GUIDINGLI
authored andcommitted
fs/romfs: Remove the reference to OK and ERROR
and fix the minor style issue Signed-off-by: Xiang Xiao <[email protected]>
1 parent 23aef2d commit 4ebcc13

File tree

2 files changed

+78
-75
lines changed

2 files changed

+78
-75
lines changed

fs/romfs/fs_romfs.c

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
188188
}
189189

190190
ret = romfs_checkmount(rm);
191-
if (ret != OK)
191+
if (ret < 0)
192192
{
193193
ferr("ERROR: romfs_checkmount failed: %d\n", ret);
194194
goto errout_with_lock;
@@ -394,7 +394,7 @@ static ssize_t romfs_read(FAR struct file *filep, FAR char *buffer,
394394
}
395395

396396
ret = romfs_checkmount(rm);
397-
if (ret != OK)
397+
if (ret < 0)
398398
{
399399
ferr("ERROR: romfs_checkmount failed: %d\n", ret);
400400
goto errout_with_lock;
@@ -553,7 +553,7 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence)
553553
}
554554

555555
ret = romfs_checkmount(rm);
556-
if (ret != OK)
556+
if (ret < 0)
557557
{
558558
ferr("ERROR: romfs_checkmount failed: %d\n", ret);
559559
goto errout_with_lock;
@@ -596,14 +596,12 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
596596

597597
rf = filep->f_priv;
598598

599-
/* Only one ioctl command is supported */
600-
601599
if (cmd == FIOC_FILEPATH)
602600
{
603601
FAR char *ptr = (FAR char *)((uintptr_t)arg);
604602
inode_getpath(filep->f_inode, ptr, PATH_MAX);
605603
strlcat(ptr, rf->rf_path, PATH_MAX);
606-
return OK;
604+
return 0;
607605
}
608606
else if (cmd == FIOC_XIPBASE)
609607
{
@@ -613,7 +611,7 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
613611
if (rm->rm_xipbase != 0)
614612
{
615613
*ptr = (uintptr_t)rm->rm_xipbase + rf->rf_startoffset;
616-
return OK;
614+
return 0;
617615
}
618616
else
619617
{
@@ -646,7 +644,7 @@ static int romfs_mmap(FAR struct file *filep, FAR struct mm_map_entry_s *map)
646644
map->length != 0 && map->offset + map->length <= rf->rf_size)
647645
{
648646
map->vaddr = rm->rm_xipbase + rf->rf_startoffset + map->offset;
649-
return OK;
647+
return 0;
650648
}
651649

652650
return -ENOTTY;
@@ -688,7 +686,7 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp)
688686
}
689687

690688
ret = romfs_checkmount(rm);
691-
if (ret != OK)
689+
if (ret < 0)
692690
{
693691
ferr("ERROR: romfs_checkmount failed: %d\n", ret);
694692
goto errout_with_lock;
@@ -731,7 +729,6 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp)
731729
/* Attach the new private date to the new struct file instance */
732730

733731
newp->f_priv = newrf;
734-
735732
rm->rm_refs++;
736733

737734
errout_with_lock:
@@ -742,7 +739,7 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp)
742739
/****************************************************************************
743740
* Name: romfs_fstat
744741
*
745-
* Description:
742+
* Description
746743
* Obtain information about an open file associated with the file
747744
* descriptor 'fd', and will write it to the area pointed to by 'buf'.
748745
*
@@ -792,7 +789,7 @@ static int romfs_fstat(FAR const struct file *filep, FAR struct stat *buf)
792789
/****************************************************************************
793790
* Name: romfs_opendir
794791
*
795-
* Description:
792+
* Description
796793
* Open a directory for read access
797794
*
798795
****************************************************************************/
@@ -830,7 +827,7 @@ static int romfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
830827
}
831828

832829
ret = romfs_checkmount(rm);
833-
if (ret != OK)
830+
if (ret < 0)
834831
{
835832
ferr("ERROR: romfs_checkmount failed: %d\n", ret);
836833
goto errout_with_lock;
@@ -868,7 +865,7 @@ static int romfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
868865

869866
*dir = &rdir->base;
870867
nxrmutex_unlock(&rm->rm_lock);
871-
return OK;
868+
return 0;
872869

873870
errout_with_lock:
874871
nxrmutex_unlock(&rm->rm_lock);
@@ -881,7 +878,8 @@ static int romfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
881878
/****************************************************************************
882879
* Name: romfs_closedir
883880
*
884-
* Description: Close the directory
881+
* Description
882+
* Close the directory
885883
*
886884
****************************************************************************/
887885

@@ -896,7 +894,8 @@ static int romfs_closedir(FAR struct inode *mountpt,
896894
/****************************************************************************
897895
* Name: romfs_readdir
898896
*
899-
* Description: Read the next directory entry
897+
* Description
898+
* Read the next directory entry
900899
*
901900
****************************************************************************/
902901

@@ -934,7 +933,7 @@ static int romfs_readdir(FAR struct inode *mountpt,
934933
}
935934

936935
ret = romfs_checkmount(rm);
937-
if (ret != OK)
936+
if (ret < 0)
938937
{
939938
ferr("ERROR: omfs_checkmount failed: %d\n", ret);
940939
goto errout_with_lock;
@@ -1019,7 +1018,8 @@ static int romfs_readdir(FAR struct inode *mountpt,
10191018
/****************************************************************************
10201019
* Name: romfs_rewindir
10211020
*
1022-
* Description: Reset directory read to the first entry
1021+
* Description
1022+
* Reset directory read to the first entry
10231023
*
10241024
****************************************************************************/
10251025

@@ -1050,7 +1050,7 @@ static int romfs_rewinddir(FAR struct inode *mountpt,
10501050
}
10511051

10521052
ret = romfs_checkmount(rm);
1053-
if (ret == OK)
1053+
if (ret >= 0)
10541054
{
10551055
#ifdef CONFIG_FS_ROMFS_CACHE_NODE
10561056
rdir->currnode = rdir->firstnode;
@@ -1066,11 +1066,12 @@ static int romfs_rewinddir(FAR struct inode *mountpt,
10661066
/****************************************************************************
10671067
* Name: romfs_bind
10681068
*
1069-
* Description: This implements a portion of the mount operation. This
1070-
* function allocates and initializes the mountpoint private data and
1071-
* binds the blockdriver inode to the filesystem private data. The final
1072-
* binding of the private data (containing the blockdriver) to the
1073-
* mountpoint is performed by mount().
1069+
* Description
1070+
* This implements a portion of the mount operation. This
1071+
* function allocates and initializes the mountpoint private data and
1072+
* binds the blockdriver inode to the filesystem private data. The final
1073+
* binding of the private data (containing the blockdriver) to the
1074+
* mountpoint is performed by mount().
10741075
*
10751076
****************************************************************************/
10761077

@@ -1091,7 +1092,7 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
10911092
}
10921093

10931094
if (blkdriver->u.i_bops->open != NULL &&
1094-
(ret = blkdriver->u.i_bops->open(blkdriver)) != OK)
1095+
(ret = blkdriver->u.i_bops->open(blkdriver)) < 0)
10951096
{
10961097
ferr("ERROR: No open method\n");
10971098
return ret;
@@ -1108,7 +1109,7 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
11081109
}
11091110

11101111
/* Initialize the allocated mountpt state structure. The filesystem is
1111-
* responsible for one reference ont the blkdriver inode and does not
1112+
* responsible for one reference on the blkdriver inode and does not
11121113
* have to addref() here (but does have to release in ubind().
11131114
*/
11141115

@@ -1171,7 +1172,7 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
11711172
/* Mounted! */
11721173

11731174
*handle = rm;
1174-
return OK;
1175+
return 0;
11751176

11761177
errout_with_buffer:
11771178
fs_heap_free(rm->rm_devbuffer);
@@ -1192,7 +1193,8 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
11921193
/****************************************************************************
11931194
* Name: romfs_unbind
11941195
*
1195-
* Description: This implements the filesystem portion of the umount
1196+
* Description
1197+
* This implements the filesystem portion of the umount
11961198
* operation.
11971199
*
11981200
****************************************************************************/
@@ -1271,7 +1273,7 @@ static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
12711273
#endif
12721274
nxrmutex_destroy(&rm->rm_lock);
12731275
fs_heap_free(rm);
1274-
return OK;
1276+
return 0;
12751277
}
12761278

12771279
nxrmutex_unlock(&rm->rm_lock);
@@ -1281,7 +1283,8 @@ static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
12811283
/****************************************************************************
12821284
* Name: romfs_statfs
12831285
*
1284-
* Description: Return filesystem statistics
1286+
* Description
1287+
* Return filesystem statistics
12851288
*
12861289
****************************************************************************/
12871290

@@ -1339,7 +1342,7 @@ static int romfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
13391342
/****************************************************************************
13401343
* Name: romfs_stat_common
13411344
*
1342-
* Description:
1345+
* Description
13431346
* Return information about a file or directory
13441347
*
13451348
****************************************************************************/
@@ -1389,13 +1392,14 @@ static int romfs_stat_common(uint8_t type, uint32_t size,
13891392
buf->st_size = size;
13901393
buf->st_blksize = sectorsize;
13911394
buf->st_blocks = (buf->st_size + sectorsize - 1) / sectorsize;
1392-
return OK;
1395+
return 0;
13931396
}
13941397

13951398
/****************************************************************************
13961399
* Name: romfs_stat
13971400
*
1398-
* Description: Return information about a file or directory
1401+
* Description
1402+
* Return information about a file or directory
13991403
*
14001404
****************************************************************************/
14011405

@@ -1426,7 +1430,7 @@ static int romfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
14261430
}
14271431

14281432
ret = romfs_checkmount(rm);
1429-
if (ret != OK)
1433+
if (ret < 0)
14301434
{
14311435
ferr("ERROR: romfs_checkmount failed: %d\n", ret);
14321436
goto errout_with_lock;

0 commit comments

Comments
 (0)