2014-11-17 18:19:35

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
fs/hfs/bfind.c | 3 +--
fs/hfs/brec.c | 3 +--
fs/hfsplus/bfind.c | 3 +--
fs/hfsplus/brec.c | 3 +--
4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index de69d8a..0e26523 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
int height, res;

tree = fd->tree;
- if (fd->bnode)
- hfs_bnode_put(fd->bnode);
+ hfs_bnode_put(fd->bnode);
fd->bnode = NULL;
nidx = tree->root;
if (!nidx)
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 9f4ee7f..3a52b2c 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
/* panic? */
hfs_bnode_put(node);
hfs_bnode_put(new_node);
- if (next_node)
- hfs_bnode_put(next_node);
+ hfs_bnode_put(next_node);
return ERR_PTR(-ENOSPC);
}

diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index c1422d9..7be88e3 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
int height, res;

tree = fd->tree;
- if (fd->bnode)
- hfs_bnode_put(fd->bnode);
+ hfs_bnode_put(fd->bnode);
fd->bnode = NULL;
nidx = tree->root;
if (!nidx)
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 6e560d5..59bab47 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
/* panic? */
hfs_bnode_put(node);
hfs_bnode_put(new_node);
- if (next_node)
- hfs_bnode_put(next_node);
+ hfs_bnode_put(next_node);
return ERR_PTR(-ENOSPC);
}

--
2.1.3


2014-11-17 19:18:34

by Viacheslav Dubeyko

[permalink] [raw]
Subject: Re: [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

On Mon, 2014-11-17 at 19:19 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Mon, 17 Nov 2014 19:13:56 +0100
>
> The hfs_bnode_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>

Thank you. It's the reasonable correction. Looks good for me.

Reviewed-by: Vyacheslav Dubeyko <[email protected]>

Thanks,
Vyacheslav Dubeyko.

> Signed-off-by: Markus Elfring <[email protected]>
> ---
> fs/hfs/bfind.c | 3 +--
> fs/hfs/brec.c | 3 +--
> fs/hfsplus/bfind.c | 3 +--
> fs/hfsplus/brec.c | 3 +--
> 4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
> index de69d8a..0e26523 100644
> --- a/fs/hfs/bfind.c
> +++ b/fs/hfs/bfind.c
> @@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
> int height, res;
>
> tree = fd->tree;
> - if (fd->bnode)
> - hfs_bnode_put(fd->bnode);
> + hfs_bnode_put(fd->bnode);
> fd->bnode = NULL;
> nidx = tree->root;
> if (!nidx)
> diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
> index 9f4ee7f..3a52b2c 100644
> --- a/fs/hfs/brec.c
> +++ b/fs/hfs/brec.c
> @@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
> /* panic? */
> hfs_bnode_put(node);
> hfs_bnode_put(new_node);
> - if (next_node)
> - hfs_bnode_put(next_node);
> + hfs_bnode_put(next_node);
> return ERR_PTR(-ENOSPC);
> }
>
> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
> index c1422d9..7be88e3 100644
> --- a/fs/hfsplus/bfind.c
> +++ b/fs/hfsplus/bfind.c
> @@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
> int height, res;
>
> tree = fd->tree;
> - if (fd->bnode)
> - hfs_bnode_put(fd->bnode);
> + hfs_bnode_put(fd->bnode);
> fd->bnode = NULL;
> nidx = tree->root;
> if (!nidx)
> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
> index 6e560d5..59bab47 100644
> --- a/fs/hfsplus/brec.c
> +++ b/fs/hfsplus/brec.c
> @@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
> /* panic? */
> hfs_bnode_put(node);
> hfs_bnode_put(new_node);
> - if (next_node)
> - hfs_bnode_put(next_node);
> + hfs_bnode_put(next_node);
> return ERR_PTR(-ENOSPC);
> }
>

2015-06-29 13:41:09

by SF Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

>> From: Markus Elfring <[email protected]>
>> Date: Mon, 17 Nov 2014 19:13:56 +0100
>>
>> The hfs_bnode_put() function tests whether its argument is NULL and then
>> returns immediately. Thus the test around the call is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>
> Thank you. It's the reasonable correction. Looks good for me.
>
> Reviewed-by: Vyacheslav Dubeyko <[email protected]>
>
> Thanks,
> Vyacheslav Dubeyko.
>
>> Signed-off-by: Markus Elfring <[email protected]>
>> ---
>> fs/hfs/bfind.c | 3 +--
>> fs/hfs/brec.c | 3 +--
>> fs/hfsplus/bfind.c | 3 +--
>> fs/hfsplus/brec.c | 3 +--
>> 4 files changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
>> index de69d8a..0e26523 100644
>> --- a/fs/hfs/bfind.c
>> +++ b/fs/hfs/bfind.c
>> @@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
>> int height, res;
>>
>> tree = fd->tree;
>> - if (fd->bnode)
>> - hfs_bnode_put(fd->bnode);
>> + hfs_bnode_put(fd->bnode);
>> fd->bnode = NULL;
>> nidx = tree->root;
>> if (!nidx)
>> diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
>> index 9f4ee7f..3a52b2c 100644
>> --- a/fs/hfs/brec.c
>> +++ b/fs/hfs/brec.c
>> @@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
>> /* panic? */
>> hfs_bnode_put(node);
>> hfs_bnode_put(new_node);
>> - if (next_node)
>> - hfs_bnode_put(next_node);
>> + hfs_bnode_put(next_node);
>> return ERR_PTR(-ENOSPC);
>> }
>>
>> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
>> index c1422d9..7be88e3 100644
>> --- a/fs/hfsplus/bfind.c
>> +++ b/fs/hfsplus/bfind.c
>> @@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
>> int height, res;
>>
>> tree = fd->tree;
>> - if (fd->bnode)
>> - hfs_bnode_put(fd->bnode);
>> + hfs_bnode_put(fd->bnode);
>> fd->bnode = NULL;
>> nidx = tree->root;
>> if (!nidx)
>> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
>> index 6e560d5..59bab47 100644
>> --- a/fs/hfsplus/brec.c
>> +++ b/fs/hfsplus/brec.c
>> @@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
>> /* panic? */
>> hfs_bnode_put(node);
>> hfs_bnode_put(new_node);
>> - if (next_node)
>> - hfs_bnode_put(next_node);
>> + hfs_bnode_put(next_node);
>> return ERR_PTR(-ENOSPC);
>> }
>>
>
>

Can this update suggestion be still integrated
into another source code repository?

Regards,
Markus