Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-04 Thread Valentin Vidić
On Wed, Sep 04, 2019 at 09:38:55AM +, David Laight wrote:
> From: Valentin Vidic
> > Sent: 03 September 2019 19:12
> > On Tue, Sep 03, 2019 at 06:32:49PM +0100, Al Viro wrote:
> > > On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> > > > +   } else if (uni == 0x) {
> > > > skip = TRUE;
> > >
> > > While we are at it, could you get rid of that 'TRUE' macro?
> > 
> > Sure, but maybe in a separate patch since TRUE/FALSE has more
> > calls than just this.
> 
> I bet you can get rid of the 'skip' variable and simplify the code
> by using continue/break/return (or maybe goto).

Seems it is not so simple - the value of skip is used to control the
behavior in the next loop iteration based on the current uni value.
So maybe just replace skip with a less confusing name.

-- 
Valentin


RE: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-04 Thread David Laight
From: Valentin Vidic
> Sent: 03 September 2019 19:12
> On Tue, Sep 03, 2019 at 06:32:49PM +0100, Al Viro wrote:
> > On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> > > + } else if (uni == 0x) {
> > >   skip = TRUE;
> >
> > While we are at it, could you get rid of that 'TRUE' macro?
> 
> Sure, but maybe in a separate patch since TRUE/FALSE has more
> calls than just this.

I bet you can get rid of the 'skip' variable and simplify the code
by using continue/break/return (or maybe goto).

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)



Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Greg Kroah-Hartman
On Tue, Sep 03, 2019 at 06:32:49PM +0100, Al Viro wrote:
> On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> > +   } else if (uni == 0x) {
> > skip = TRUE;
> 
> While we are at it, could you get rid of that 'TRUE' macro?
> Or added
> 
> #define THE_TRUTH_AND_THATS_CUTTIN_ME_OWN_THROAT true
> 
> if you want to properly emphasize it...

No, we don't :)

I cleaned up a bunch of those, there are a lot more still left, it is a
mess...


Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Valentin Vidić
On Tue, Sep 03, 2019 at 06:32:49PM +0100, Al Viro wrote:
> On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> > +   } else if (uni == 0x) {
> > skip = TRUE;
> 
> While we are at it, could you get rid of that 'TRUE' macro?

Sure, but maybe in a separate patch since TRUE/FALSE has more
calls than just this.

-- 
Valentin


Re: [PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Al Viro
On Tue, Sep 03, 2019 at 06:47:32PM +0200, Valentin Vidic wrote:
> + } else if (uni == 0x) {
>   skip = TRUE;

While we are at it, could you get rid of that 'TRUE' macro?
Or added

#define THE_TRUTH_AND_THATS_CUTTIN_ME_OWN_THROAT true

if you want to properly emphasize it...


[PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Unbalanced braces around else statement
  CHECK: braces {} should be used on all arms of this statement

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 12 ++--
 drivers/staging/exfat/exfat_super.c | 16 +---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..1246afcffb8d 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -743,11 +743,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
pr_debug("to 0x%X (amount of 0x%X)\n",
 index, uni);
skip = FALSE;
-   } else if (uni == index)
+   } else if (uni == index) {
index++;
-   else if (uni == 0x)
+   } else if (uni == 0x) {
skip = TRUE;
-   else { /* uni != index , uni != 0x */
+   } else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
if (upcase_table[col_index] == NULL) {
@@ -805,11 +805,11 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n", index, uni);
skip = FALSE;
-   } else if (uni == index)
+   } else if (uni == index) {
index++;
-   else if (uni == 0x)
+   } else if (uni == 0x) {
skip = TRUE;
-   else { /* uni != index , uni != 0x */
+   } else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
if (upcase_table[col_index] == NULL) {
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 881cd85cf677..e44b860e35e8 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -344,8 +344,10 @@ static int exfat_cmpi(const struct dentry *dentry, 
unsigned int len,
if (t == NULL) {
if (strncasecmp(name->name, str, alen) == 0)
return 0;
-   } else if (nls_strnicmp(t, name->name, str, alen) == 0)
-   return 0;
+   } else {
+   if (nls_strnicmp(t, name->name, str, alen) == 0)
+   return 0;
+   }
}
return 1;
 }
@@ -999,7 +1001,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
   _clu);
if (num_alloced == 0)
break;
-   else if (num_alloced < 0) {
+   if (num_alloced < 0) {
ret = FFS_MEDIAERR;
goto out;
}
@@ -1248,9 +1250,9 @@ static int ffsTruncateFile(struct inode *inode, u64 
old_size, u64 new_size)
p_fs->fs_func->set_entry_clu0(ep2, CLUSTER_32(0));
}
 
-   if (p_fs->vol_type != EXFAT)
+   if (p_fs->vol_type != EXFAT) {
buf_modify(sb, sector);
-   else {
+   } else {
update_dir_checksum_with_entry_set(sb, es);
release_entry_set(es);
}
@@ -1561,9 +1563,9 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
fid->attr = attr;
p_fs->fs_func->set_entry_attr(ep, attr);
 
-   if (p_fs->vol_type != EXFAT)
+   if (p_fs->vol_type != EXFAT) {
buf_modify(sb, sector);
-   else {
+   } else {
update_dir_checksum_with_entry_set(sb, es);
release_entry_set(es);
}
-- 
2.20.1