public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct
@ 2016-07-27  3:11 Salah Triki
  2016-07-27  3:11 ` [RESEND PATCH 2/4] fs: befs: Coding style fix Salah Triki
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Salah Triki @ 2016-07-27  3:11 UTC (permalink / raw)
  To: akpm, viro
  Cc: luisbg, mhocko, vdavydov, linux-fsdevel, linux-kernel,
	salah.triki

The only caller of befs_find_brun_direct is befs_fblock2brun, which
already validates that the block is within the range of direct blocks.
So remove the duplicate validation.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
Acked-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
 fs/befs/datastream.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 26cc417..e224b9a 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -249,17 +249,9 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data,
 	int i;
 	const befs_block_run *array = data->direct;
 	befs_blocknr_t sum;
-	befs_blocknr_t max_block =
-	    data->max_direct_range >> BEFS_SB(sb)->block_shift;
 
 	befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno);
 
-	if (blockno > max_block) {
-		befs_error(sb, "%s passed block outside of direct region",
-			   __func__);
-		return BEFS_ERR;
-	}
-
 	for (i = 0, sum = 0; i < BEFS_NUM_DIRECT_BLOCKS;
 	     sum += array[i].len, i++) {
 		if (blockno >= sum && blockno < sum + (array[i].len)) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RESEND PATCH 2/4] fs: befs: Coding style fix
  2016-07-27  3:11 [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki
@ 2016-07-27  3:11 ` Salah Triki
  2016-07-27  3:11 ` [RESEND PATCH 3/4] fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect Salah Triki
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Salah Triki @ 2016-07-27  3:11 UTC (permalink / raw)
  To: akpm, viro
  Cc: luisbg, mhocko, vdavydov, linux-fsdevel, linux-kernel,
	salah.triki

Constant has to be capitalized.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
Acked-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
 fs/befs/btree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 307645f9..e59ad20 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -85,7 +85,7 @@ struct befs_btree_node {
 };
 
 /* local constants */
-static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL;
+static const befs_off_t BEFS_BT_INVAL = 0xffffffffffffffffULL;
 
 /* local functions */
 static int befs_btree_seekleaf(struct super_block *sb, const befs_data_stream *ds,
@@ -467,7 +467,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
 	while (key_sum + this_node->head.all_key_count <= key_no) {
 
 		/* no more nodes to look in: key_no is too large */
-		if (this_node->head.right == befs_bt_inval) {
+		if (this_node->head.right == BEFS_BT_INVAL) {
 			*keysize = 0;
 			*value = 0;
 			befs_debug(sb,
@@ -608,7 +608,7 @@ static int
 befs_leafnode(struct befs_btree_node *node)
 {
 	/* all interior nodes (and only interior nodes) have an overflow node */
-	if (node->head.overflow == befs_bt_inval)
+	if (node->head.overflow == BEFS_BT_INVAL)
 		return 1;
 	else
 		return 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RESEND PATCH 3/4] fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect
  2016-07-27  3:11 [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki
  2016-07-27  3:11 ` [RESEND PATCH 2/4] fs: befs: Coding style fix Salah Triki
@ 2016-07-27  3:11 ` Salah Triki
  2016-07-27  3:11 ` [RESEND PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr Salah Triki
  2016-07-27 15:22 ` [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Luis de Bethencourt
  3 siblings, 0 replies; 6+ messages in thread
From: Salah Triki @ 2016-07-27  3:11 UTC (permalink / raw)
  To: akpm, viro
  Cc: luisbg, mhocko, vdavydov, linux-fsdevel, linux-kernel,
	salah.triki

The calls to brelse are useless since dbl_indir_block and indir_block
are NULL.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
Acked-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
 fs/befs/datastream.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index e224b9a..b68b6f9 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -471,7 +471,6 @@ befs_find_brun_dblindirect(struct super_block *sb,
 			   (unsigned long)
 			   iaddr2blockno(sb, &data->double_indirect) +
 			   dbl_which_block);
-		brelse(dbl_indir_block);
 		return BEFS_ERR;
 	}
 
@@ -496,7 +495,6 @@ befs_find_brun_dblindirect(struct super_block *sb,
 		befs_error(sb, "%s couldn't read the indirect block "
 			   "at blockno %lu", __func__, (unsigned long)
 			   iaddr2blockno(sb, &indir_run) + which_block);
-		brelse(indir_block);
 		return BEFS_ERR;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RESEND PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr
  2016-07-27  3:11 [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki
  2016-07-27  3:11 ` [RESEND PATCH 2/4] fs: befs: Coding style fix Salah Triki
  2016-07-27  3:11 ` [RESEND PATCH 3/4] fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect Salah Triki
@ 2016-07-27  3:11 ` Salah Triki
  2016-07-27 15:32   ` Luis de Bethencourt
  2016-07-27 15:22 ` [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Luis de Bethencourt
  3 siblings, 1 reply; 6+ messages in thread
From: Salah Triki @ 2016-07-27  3:11 UTC (permalink / raw)
  To: akpm, viro
  Cc: luisbg, mhocko, vdavydov, linux-fsdevel, linux-kernel,
	salah.triki

Since goto statement merely returns NULL, replace it with return
statement.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 fs/befs/io.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/befs/io.c b/fs/befs/io.c
index 4223b77..af631a6 100644
--- a/fs/befs/io.c
+++ b/fs/befs/io.c
@@ -37,7 +37,7 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
 	if (iaddr.allocation_group > befs_sb->num_ags) {
 		befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
 			   iaddr.allocation_group, befs_sb->num_ags);
-		goto error;
+		return NULL;
 	}
 
 	block = iaddr2blockno(sb, &iaddr);
@@ -49,13 +49,9 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
 	if (bh == NULL) {
 		befs_error(sb, "Failed to read block %lu",
 			   (unsigned long)block);
-		goto error;
+		return NULL;
 	}
 
 	befs_debug(sb, "<--- %s", __func__);
 	return bh;
-
-      error:
-	befs_debug(sb, "<--- %s ERROR", __func__);
-	return NULL;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct
  2016-07-27  3:11 [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki
                   ` (2 preceding siblings ...)
  2016-07-27  3:11 ` [RESEND PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr Salah Triki
@ 2016-07-27 15:22 ` Luis de Bethencourt
  3 siblings, 0 replies; 6+ messages in thread
From: Luis de Bethencourt @ 2016-07-27 15:22 UTC (permalink / raw)
  To: Salah Triki, akpm, viro; +Cc: mhocko, vdavydov, linux-fsdevel, linux-kernel

On 27/07/16 04:11, Salah Triki wrote:
> The only caller of befs_find_brun_direct is befs_fblock2brun, which
> already validates that the block is within the range of direct blocks.
> So remove the duplicate validation.
> 
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> Acked-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
>  fs/befs/datastream.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
> index 26cc417..e224b9a 100644
> --- a/fs/befs/datastream.c
> +++ b/fs/befs/datastream.c
> @@ -249,17 +249,9 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data,
>  	int i;
>  	const befs_block_run *array = data->direct;
>  	befs_blocknr_t sum;
> -	befs_blocknr_t max_block =
> -	    data->max_direct_range >> BEFS_SB(sb)->block_shift;
>  
>  	befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno);
>  
> -	if (blockno > max_block) {
> -		befs_error(sb, "%s passed block outside of direct region",
> -			   __func__);
> -		return BEFS_ERR;
> -	}
> -
>  	for (i = 0, sum = 0; i < BEFS_NUM_DIRECT_BLOCKS;
>  	     sum += array[i].len, i++) {
>  		if (blockno >= sum && blockno < sum + (array[i].len)) {
> 

Hi,

I have applied 1, 2 and 3 from this series into:
https://github.com/luisbg/linux-befs/tree/befs-next

I had already tested and acked the 3 commits above. Having them in the above git
branch [0] makes it easier to see the order of all recent commits.

Andrew,
I hope this process works for you. If not, let me know and I can adapt to however
you prefer it to be.

Thanks Salah :)

Luis



[0] reason for that git branch: https://lkml.org/lkml/2016/7/26/533

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr
  2016-07-27  3:11 ` [RESEND PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr Salah Triki
@ 2016-07-27 15:32   ` Luis de Bethencourt
  0 siblings, 0 replies; 6+ messages in thread
From: Luis de Bethencourt @ 2016-07-27 15:32 UTC (permalink / raw)
  To: Salah Triki, akpm, viro; +Cc: mhocko, vdavydov, linux-fsdevel, linux-kernel

On 27/07/16 04:11, Salah Triki wrote:
> Since goto statement merely returns NULL, replace it with return
> statement.
> 
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
>  fs/befs/io.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/befs/io.c b/fs/befs/io.c
> index 4223b77..af631a6 100644
> --- a/fs/befs/io.c
> +++ b/fs/befs/io.c
> @@ -37,7 +37,7 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
>  	if (iaddr.allocation_group > befs_sb->num_ags) {
>  		befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
>  			   iaddr.allocation_group, befs_sb->num_ags);
> -		goto error;
> +		return NULL;
>  	}
>  
>  	block = iaddr2blockno(sb, &iaddr);
> @@ -49,13 +49,9 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
>  	if (bh == NULL) {
>  		befs_error(sb, "Failed to read block %lu",
>  			   (unsigned long)block);
> -		goto error;
> +		return NULL;
>  	}
>  
>  	befs_debug(sb, "<--- %s", __func__);
>  	return bh;
> -
> -      error:
> -	befs_debug(sb, "<--- %s ERROR", __func__);
> -	return NULL;
>  }
> 

Hi Salah,

The goto statement also calls the debug function. I  know it doesn't look pretty
to have "debug; return; label; debug; return;", but I find these debug calls at
the start and end of functions very useful when reading dmesg to see that all
functions entered and exited correctly.

I prefer not removing that befs_debug(... ERROR ...);
Unless anybody else agree this is a good patch.

Thanks,
Luis

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-07-27 15:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-27  3:11 [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki
2016-07-27  3:11 ` [RESEND PATCH 2/4] fs: befs: Coding style fix Salah Triki
2016-07-27  3:11 ` [RESEND PATCH 3/4] fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect Salah Triki
2016-07-27  3:11 ` [RESEND PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr Salah Triki
2016-07-27 15:32   ` Luis de Bethencourt
2016-07-27 15:22 ` [RESEND PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Luis de Bethencourt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox