Re: [PATCH v2 07/10] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-11-04 Thread Dan Carpenter
On Mon, Nov 04, 2019 at 05:53:55AM -0500, Valdis Klētnieks wrote:
> On Mon, 04 Nov 2019 13:04:14 +0300, Dan Carpenter said:
> > On Sun, Nov 03, 2019 at 08:45:03PM -0500, Valdis Kletnieks wrote:
> > > - if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
> > > + if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
> >
> > It's better to just remove the "!= 0" double negative.  != 0 should be
> > used when we are talking about the number zero as in "cnt != 0" and for
> > "strcmp(foo, bar) != 0" where it means that "foo != bar".
> 
> "Fix up ==0 and !=0" is indeed on the to-do list.
> 
> This patch converted 82 uses of FFS_SUCCESS, of which 33 had the != idiom in
> use.  Meanwhile, overall there's 53 '!= 0' and 95 '== 0' uses.
> 
> In other words, even if I fixed all of those that were involved in this patch,
> there would *still* be more patching to do.

Very good.  Sounds like the plan.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 07/10] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-11-04 Thread Valdis Klētnieks
On Mon, 04 Nov 2019 13:04:14 +0300, Dan Carpenter said:
> On Sun, Nov 03, 2019 at 08:45:03PM -0500, Valdis Kletnieks wrote:
> > -   if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
> > +   if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
>
> It's better to just remove the "!= 0" double negative.  != 0 should be
> used when we are talking about the number zero as in "cnt != 0" and for
> "strcmp(foo, bar) != 0" where it means that "foo != bar".

"Fix up ==0 and !=0" is indeed on the to-do list.

This patch converted 82 uses of FFS_SUCCESS, of which 33 had the != idiom in
use.  Meanwhile, overall there's 53 '!= 0' and 95 '== 0' uses.

In other words, even if I fixed all of those that were involved in this patch,
there would *still* be more patching to do.






pgp5fC7PakFly.pgp
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 07/10] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-11-04 Thread Dan Carpenter
On Sun, Nov 03, 2019 at 08:45:03PM -0500, Valdis Kletnieks wrote:
> diff --git a/drivers/staging/exfat/exfat_cache.c 
> b/drivers/staging/exfat/exfat_cache.c
> index 467b93630d86..28a67f8139ea 100644
> --- a/drivers/staging/exfat/exfat_cache.c
> +++ b/drivers/staging/exfat/exfat_cache.c
> @@ -462,7 +462,7 @@ u8 *FAT_getblk(struct super_block *sb, sector_t sec)
>  
>   FAT_cache_insert_hash(sb, bp);
>  
> - if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
> + if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {

It's better to just remove the "!= 0" double negative.  != 0 should be
used when we are talking about the number zero as in "cnt != 0" and for
"strcmp(foo, bar) != 0" where it means that "foo != bar".

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 07/10] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-11-03 Thread Valdis Kletnieks
Convert FFS_SUCCESS to 0.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |   3 -
 drivers/staging/exfat/exfat_cache.c |   4 +-
 drivers/staging/exfat/exfat_core.c  | 104 ++--
 drivers/staging/exfat/exfat_super.c |  50 ++---
 4 files changed, 79 insertions(+), 82 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index b3fc9bb06c24..72cf40e123de 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -208,9 +208,6 @@ static inline u16 get_row_index(u16 i)
 #define FM_REGULAR  0x00
 #define FM_SYMLINK  0x40
 
-/* return values */
-#define FFS_SUCCESS 0
-
 #define NUM_UPCASE  2918
 
 #define DOS_CUR_DIR_NAME".  "
diff --git a/drivers/staging/exfat/exfat_cache.c 
b/drivers/staging/exfat/exfat_cache.c
index 467b93630d86..28a67f8139ea 100644
--- a/drivers/staging/exfat/exfat_cache.c
+++ b/drivers/staging/exfat/exfat_cache.c
@@ -462,7 +462,7 @@ u8 *FAT_getblk(struct super_block *sb, sector_t sec)
 
FAT_cache_insert_hash(sb, bp);
 
-   if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
+   if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
FAT_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
@@ -582,7 +582,7 @@ static u8 *__buf_getblk(struct super_block *sb, sector_t 
sec)
 
buf_cache_insert_hash(sb, bp);
 
-   if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
+   if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
buf_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index ffcad6867ecb..1f0ef94bdd47 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -102,7 +102,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
if (p_fs->vol_type == EXFAT) {
if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
-   &p_fs->pbr_bh, 1) != FFS_SUCCESS)
+   &p_fs->pbr_bh, 1) != 0)
return;
}
 
@@ -139,7 +139,7 @@ void fs_error(struct super_block *sb)
 s32 clear_cluster(struct super_block *sb, u32 clu)
 {
sector_t s, n;
-   s32 ret = FFS_SUCCESS;
+   s32 ret = 0;
struct buffer_head *tmp_bh = NULL;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
@@ -154,12 +154,12 @@ s32 clear_cluster(struct super_block *sb, u32 clu)
 
for (; s < n; s++) {
ret = sector_read(sb, s, &tmp_bh, 0);
-   if (ret != FFS_SUCCESS)
+   if (ret != 0)
return ret;
 
memset((char *)tmp_bh->b_data, 0x0, p_bd->sector_size);
ret = sector_write(sb, s, tmp_bh, 0);
-   if (ret != FFS_SUCCESS)
+   if (ret != 0)
break;
}
 
@@ -251,7 +251,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
}
 
-   if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
+   if (set_alloc_bitmap(sb, new_clu - 2) != 0)
return -EIO;
 
num_clusters++;
@@ -370,7 +370,7 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != 0)
break;
clu++;
 
@@ -387,7 +387,7 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != 0)
break;
 
if (FAT_read(sb, clu, &clu) == -1)
@@ -552,7 +552,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
for (j = 0; j < p_fs->map_sectors; j++) {
p_fs->vol_amap[j] = NULL;
ret = sector_read(sb, sector + j, 
&p_fs->vol_amap[j], 1);
-   if (ret != FFS_SUCCESS) {
+   if (ret != 0) {
/*  release all buffers and 
free vol_amap */
i = 0;
while (i < j)
@@ -565,