2011-08-04 10:29:41

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/4] fs/ext3/balloc.c: delete useless initialization

From: Julia Lawall <[email protected]>

Delete nontrivial initialization that is immediately overwritten by the
result of an allocation function.

The semantic match that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
identifier i;
expression e;
@@

(
T i = \(0\|NULL\|ERR_PTR(...)\);
|
-T i = e;
+T i;
)
... when != i
i = \(kzalloc\|kcalloc\|kmalloc\)(...);

// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
fs/ext3/balloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/fs/ext3/balloc.c b/fs/ext3/balloc.c
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -427,7 +427,7 @@ static inline int rsv_is_empty(struct ex
void ext3_init_block_alloc_info(struct inode *inode)
{
struct ext3_inode_info *ei = EXT3_I(inode);
- struct ext3_block_alloc_info *block_i = ei->i_block_alloc_info;
+ struct ext3_block_alloc_info *block_i;
struct super_block *sb = inode->i_sb;

block_i = kmalloc(sizeof(*block_i), GFP_NOFS);



2011-08-04 10:40:03

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 1/4] fs/ext3/balloc.c: delete useless initialization

On Thu 04-08-11 12:29:31, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Delete nontrivial initialization that is immediately overwritten by the
> result of an allocation function.
Thanks. Merged.

Honza

>
> The semantic match that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> type T;
> identifier i;
> expression e;
> @@
>
> (
> T i = \(0\|NULL\|ERR_PTR(...)\);
> |
> -T i = e;
> +T i;
> )
> ... when != i
> i = \(kzalloc\|kcalloc\|kmalloc\)(...);
>
> // </smpl>
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> fs/ext3/balloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff -u -p a/fs/ext3/balloc.c b/fs/ext3/balloc.c
> --- a/fs/ext3/balloc.c
> +++ b/fs/ext3/balloc.c
> @@ -427,7 +427,7 @@ static inline int rsv_is_empty(struct ex
> void ext3_init_block_alloc_info(struct inode *inode)
> {
> struct ext3_inode_info *ei = EXT3_I(inode);
> - struct ext3_block_alloc_info *block_i = ei->i_block_alloc_info;
> + struct ext3_block_alloc_info *block_i;
> struct super_block *sb = inode->i_sb;
>
> block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2011-08-05 17:25:01

by Eric Sandeen

[permalink] [raw]
Subject: Re: [PATCH 1/4] fs/ext3/balloc.c: delete useless initialization

On 8/4/11 5:40 AM, Jan Kara wrote:
> On Thu 04-08-11 12:29:31, Julia Lawall wrote:
>> From: Julia Lawall <[email protected]>
>>
>> Delete nontrivial initialization that is immediately overwritten by the
>> result of an allocation function.
> Thanks. Merged.

Just FWIW, I was curious how this ended up here.

It looks like this has been there since 2005, and both
lines went in in the same commit (i.e. it didn't creep in over time).

http://git.kernel.org/?p=linux/kernel/git/torvalds/old-2.6-bkcvs.git;a=commitdiff;h=a66d457d8878fe8d09bc81f0d5e6ac40caec6eb7

-Eric

> Honza
>
>>
>> The semantic match that makes this change is as follows:
>> (http://coccinelle.lip6.fr/)
>>
>> // <smpl>
>> @@
>> type T;
>> identifier i;
>> expression e;
>> @@
>>
>> (
>> T i = \(0\|NULL\|ERR_PTR(...)\);
>> |
>> -T i = e;
>> +T i;
>> )
>> ... when != i
>> i = \(kzalloc\|kcalloc\|kmalloc\)(...);
>>
>> // </smpl>
>>
>> Signed-off-by: Julia Lawall <[email protected]>
>>
>> ---
>> fs/ext3/balloc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff -u -p a/fs/ext3/balloc.c b/fs/ext3/balloc.c
>> --- a/fs/ext3/balloc.c
>> +++ b/fs/ext3/balloc.c
>> @@ -427,7 +427,7 @@ static inline int rsv_is_empty(struct ex
>> void ext3_init_block_alloc_info(struct inode *inode)
>> {
>> struct ext3_inode_info *ei = EXT3_I(inode);
>> - struct ext3_block_alloc_info *block_i = ei->i_block_alloc_info;
>> + struct ext3_block_alloc_info *block_i;
>> struct super_block *sb = inode->i_sb;
>>
>> block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
>>


2011-08-05 19:08:19

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 1/4] fs/ext3/balloc.c: delete useless initialization

On Fri, 5 Aug 2011, Eric Sandeen wrote:

> On 8/4/11 5:40 AM, Jan Kara wrote:
> > On Thu 04-08-11 12:29:31, Julia Lawall wrote:
> >> From: Julia Lawall <[email protected]>
> >>
> >> Delete nontrivial initialization that is immediately overwritten by the
> >> result of an allocation function.
> > Thanks. Merged.
>
> Just FWIW, I was curious how this ended up here.
>
> It looks like this has been there since 2005, and both
> lines went in in the same commit (i.e. it didn't creep in over time).
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/old-2.6-bkcvs.git;a=commitdiff;h=a66d457d8878fe8d09bc81f0d5e6ac40caec6eb7

Actually, the old code had the same property, for the rsv variable...

julia