Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1435800
| From | Luis de Bethencourt <luisbg@osg.samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct |
| Date | 2016-07-02 13:40 +0200 |
| Message-ID | <rQrrb-31L-9@gated-at.bofh.it> (permalink) |
| References | <rQo9X-14M-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 02/07/16 09:05, 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>
> ---
> 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 Salah,
These aren't the same check though. If we ignore the BEFS_SB(sb)->block_shift just to
comparing them, we can consider the checks to be the following.
In befs_fblock2brun():
if (fblock < data->max_direct_range)
In befs_find_brun_direct():
if (fblock > data->max_direct_range)
Notice how one checks if the block is past the range, and the other checks if it isn't
before it.
They also looked similar to me the first time I saw them and I had to double-check :)
Thanks,
Luis
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki <salah.triki@gmail.com> - 2016-07-02 10:10 +0200
[PATCH 3/4] fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect Salah Triki <salah.triki@gmail.com> - 2016-07-02 10:10 +0200
Re: [PATCH 3/4] fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect Luis de Bethencourt <luisbg@osg.samsung.com> - 2016-07-02 14:00 +0200
[PATCH 2/4] fs: befs: Coding style fix Salah Triki <salah.triki@gmail.com> - 2016-07-02 10:10 +0200
Re: [PATCH 2/4] fs: befs: Coding style fix Luis de Bethencourt <luisbg@osg.samsung.com> - 2016-07-02 13:30 +0200
[PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr Salah Triki <salah.triki@gmail.com> - 2016-07-02 10:10 +0200
Re: [PATCH 4/4] fs: befs: Remove goto from befs_bread_iaddr Luis de Bethencourt <luisbg@osg.samsung.com> - 2016-07-02 14:10 +0200
Re: [PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Luis de Bethencourt <luisbg@osg.samsung.com> - 2016-07-02 13:40 +0200
Re: [PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Salah Triki <salah.triki@acm.org> - 2016-07-02 16:00 +0200
Re: [PATCH 1/4] fs: befs: Remove redundant validation from befs_find_brun_direct Luis de Bethencourt <luisbg@osg.samsung.com> - 2016-07-02 16:50 +0200
csiph-web