diff mbox series

[04/15] staging: exfat: Clean up return codes - FFS_PERMISSIONERR

Message ID 20191024155327.1095907-5-Valdis.Kletnieks@vt.edu (mailing list archive)
State New, archived
Headers show
Series staging: exfat: Clean up return codes | expand

Commit Message

Valdis Klētnieks Oct. 24, 2019, 3:53 p.m. UTC
Convert FFS_PERMISSIONERR to -EPERM

Signed-off-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
---
 drivers/staging/exfat/exfat.h       |  1 -
 drivers/staging/exfat/exfat_super.c | 20 ++++++++++----------
 2 files changed, 10 insertions(+), 11 deletions(-)

Comments

Joe Perches Oct. 24, 2019, 4:23 p.m. UTC | #1
On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> Convert FFS_PERMISSIONERR to -EPERM
[]
> diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
[]
> @@ -2526,7 +2526,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
>  
>  	err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid));
>  	if (err) {
> -		if (err == FFS_PERMISSIONERR)
> +		if (err == -EPERM)
>  			err = -EPERM;
>  		else
>  			err = -EIO;
[]
> @@ -2746,7 +2746,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir,
>  			  new_dentry);
>  	if (err) {
> -		if (err == FFS_PERMISSIONERR)
> +		if (err == -EPERM)
>  			err = -EPERM;
>  		else if (err == FFS_INVALIDPATH)
>  			err = -EINVAL;

These test and assign to same value blocks look kinda silly.
Valdis Klētnieks Oct. 24, 2019, 4:27 p.m. UTC | #2
On Thu, 24 Oct 2019 09:23:33 -0700, Joe Perches said:
> On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:

> >  	if (err) {
> > -		if (err == FFS_PERMISSIONERR)
> > +		if (err == -EPERM)
> >  			err = -EPERM;
> >  		else if (err == FFS_INVALIDPATH)
> >  			err = -EINVAL;
>
> These test and assign to same value blocks look kinda silly.

One patch, one thing.  Those are getting cleaned up in a subsequent patch.:)
Dan Carpenter Oct. 25, 2019, 10:14 a.m. UTC | #3
On Thu, Oct 24, 2019 at 12:27:47PM -0400, Valdis Klētnieks wrote:
> On Thu, 24 Oct 2019 09:23:33 -0700, Joe Perches said:
> > On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> 
> > >  	if (err) {
> > > -		if (err == FFS_PERMISSIONERR)
> > > +		if (err == -EPERM)
> > >  			err = -EPERM;
> > >  		else if (err == FFS_INVALIDPATH)
> > >  			err = -EINVAL;
> >
> > These test and assign to same value blocks look kinda silly.
> 
> One patch, one thing.  Those are getting cleaned up in a subsequent patch.:)

I was just giving an impromptu lecture on this last week....  The one
thing per patch means we cleanup the fallout that results from the
change.  So if you rename a function then you have re-indent the
parameters etc.  If you remove a cast from (type)(foo + bar) then
remove all the extra parentheses and so on.

(I don't have strong feelings about this patch, but I have just been
trying to explain the one thing rule recently).

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index ec52237b01cd..86bdcf222a5a 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -217,7 +217,6 @@  static inline u16 get_row_index(u16 i)
 #define FFS_INVALIDPATH         7
 #define FFS_INVALIDFID          8
 #define FFS_FILEEXIST           10
-#define FFS_PERMISSIONERR       11
 #define FFS_NOTOPENED           12
 #define FFS_MAXOPENED           13
 #define FFS_EOF                 15
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 566cfba0a522..fd5d8ba0d8bc 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -702,7 +702,7 @@  static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
 
 	/* check if the given file ID is opened */
 	if (fid->type != TYPE_FILE) {
-		ret = FFS_PERMISSIONERR;
+		ret = -EPERM;
 		goto out;
 	}
 
@@ -832,7 +832,7 @@  static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
 
 	/* check if the given file ID is opened */
 	if (fid->type != TYPE_FILE) {
-		ret = FFS_PERMISSIONERR;
+		ret = -EPERM;
 		goto out;
 	}
 
@@ -1079,7 +1079,7 @@  static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
 
 	/* check if the given file ID is opened */
 	if (fid->type != TYPE_FILE) {
-		ret = FFS_PERMISSIONERR;
+		ret = -EPERM;
 		goto out;
 	}
 
@@ -1246,7 +1246,7 @@  static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
 	/* check if the old file is "." or ".." */
 	if (p_fs->vol_type != EXFAT) {
 		if ((olddir.dir != p_fs->root_dir) && (dentry < 2)) {
-			ret = FFS_PERMISSIONERR;
+			ret = -EPERM;
 			goto out2;
 		}
 	}
@@ -1258,7 +1258,7 @@  static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
 	}
 
 	if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) {
-		ret = FFS_PERMISSIONERR;
+		ret = -EPERM;
 		goto out2;
 	}
 
@@ -1365,7 +1365,7 @@  static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
 	}
 
 	if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) {
-		ret = FFS_PERMISSIONERR;
+		ret = -EPERM;
 		goto out;
 	}
 	fs_set_vol_flags(sb, VOL_DIRTY);
@@ -1947,7 +1947,7 @@  static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
 
 	/* check if the given file ID is opened */
 	if (fid->type != TYPE_DIR)
-		return FFS_PERMISSIONERR;
+		return -EPERM;
 
 	/* acquire the lock for file system critical section */
 	down(&p_fs->v_sem);
@@ -2145,7 +2145,7 @@  static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
 	/* check if the file is "." or ".." */
 	if (p_fs->vol_type != EXFAT) {
 		if ((dir.dir != p_fs->root_dir) && (dentry < 2))
-			return FFS_PERMISSIONERR;
+			return -EPERM;
 	}
 
 	/* acquire the lock for file system critical section */
@@ -2526,7 +2526,7 @@  static int exfat_unlink(struct inode *dir, struct dentry *dentry)
 
 	err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid));
 	if (err) {
-		if (err == FFS_PERMISSIONERR)
+		if (err == -EPERM)
 			err = -EPERM;
 		else
 			err = -EIO;
@@ -2746,7 +2746,7 @@  static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
 	err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir,
 			  new_dentry);
 	if (err) {
-		if (err == FFS_PERMISSIONERR)
+		if (err == -EPERM)
 			err = -EPERM;
 		else if (err == FFS_INVALIDPATH)
 			err = -EINVAL;