linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] befs/btree: remove unneeded initializations
@ 2016-05-30  0:39 Luis de Bethencourt
  2016-06-01 22:42 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Luis de Bethencourt @ 2016-05-30  0:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, viro, fabf, Luis de Bethencourt

off in befs_bt_read_node() will be written by befs_read_datastream(), with
the value that node->od_node needs.

node_off in befs_btree_read() isn't read before set to root_node_ptr.

Removing these two unneeded initializations.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---

Hi,

Also saw these while reading the code.

Thanks :)
Luis

 fs/befs/btree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 307645f9..3bd8ab6 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -196,7 +196,7 @@ static int
 befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds,
 		  struct befs_btree_node *node, befs_off_t node_off)
 {
-	uint off = 0;
+	uint off;
 
 	befs_debug(sb, "---> %s", __func__);
 
@@ -422,7 +422,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
 {
 	struct befs_btree_node *this_node;
 	befs_btree_super bt_super;
-	befs_off_t node_off = 0;
+	befs_off_t node_off;
 	int cur_key;
 	fs64 *valarray;
 	char *keystart;
-- 
2.5.1

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

* Re: [PATCH] befs/btree: remove unneeded initializations
  2016-05-30  0:39 [PATCH] befs/btree: remove unneeded initializations Luis de Bethencourt
@ 2016-06-01 22:42 ` Andrew Morton
  2016-06-01 23:43   ` Luis de Bethencourt
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2016-06-01 22:42 UTC (permalink / raw)
  To: Luis de Bethencourt; +Cc: linux-kernel, viro, fabf

On Mon, 30 May 2016 01:39:59 +0100 Luis de Bethencourt <luisbg@osg.samsung.com> wrote:

> off in befs_bt_read_node() will be written by befs_read_datastream(), with
> the value that node->od_node needs.
> 
> node_off in befs_btree_read() isn't read before set to root_node_ptr.
> 
> Removing these two unneeded initializations.
>
> ...
>
> --- a/fs/befs/btree.c
> +++ b/fs/befs/btree.c
> @@ -196,7 +196,7 @@ static int
>  befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds,
>  		  struct befs_btree_node *node, befs_off_t node_off)
>  {
> -	uint off = 0;
> +	uint off;
>  
>  	befs_debug(sb, "---> %s", __func__);
>  

With this code:

	int foo;

	bar(&foo);

	whatever = foo;

some versions of gcc will warn that foo might be used uninitialized. 
Other versions of gcc don't do this.  That's why the seemingly-unneeded
initializations are there.

Neither of the versions of gcc which I tested with actually do warn,
but I'm inclined to leave things as-is: some people will get warnings
and that's probably worse than a couple of bytes bloat in befs.

It shouldn't cause any bloat, really.  We have the "uninitialized_var"
macro which avoids any bloat and is self-documenting.  And the nice
thing about self-documenting code is that it prevents Andrew from
having to explain strange code to Luis ;)  But unintialized_var in
unpopular for reasons which I personally find unpersuasive, given
the advantages...

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

* Re: [PATCH] befs/btree: remove unneeded initializations
  2016-06-01 22:42 ` Andrew Morton
@ 2016-06-01 23:43   ` Luis de Bethencourt
  0 siblings, 0 replies; 3+ messages in thread
From: Luis de Bethencourt @ 2016-06-01 23:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, viro, fabf

On 01/06/16 23:42, Andrew Morton wrote:
> On Mon, 30 May 2016 01:39:59 +0100 Luis de Bethencourt <luisbg@osg.samsung.com> wrote:
> 
>> off in befs_bt_read_node() will be written by befs_read_datastream(), with
>> the value that node->od_node needs.
>>
>> node_off in befs_btree_read() isn't read before set to root_node_ptr.
>>
>> Removing these two unneeded initializations.
>>
>> ...
>>
>> --- a/fs/befs/btree.c
>> +++ b/fs/befs/btree.c
>> @@ -196,7 +196,7 @@ static int
>>  befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds,
>>  		  struct befs_btree_node *node, befs_off_t node_off)
>>  {
>> -	uint off = 0;
>> +	uint off;
>>  
>>  	befs_debug(sb, "---> %s", __func__);
>>  
> 
> With this code:
> 
> 	int foo;
> 
> 	bar(&foo);
> 
> 	whatever = foo;
> 
> some versions of gcc will warn that foo might be used uninitialized. 
> Other versions of gcc don't do this.  That's why the seemingly-unneeded
> initializations are there.
> 
> Neither of the versions of gcc which I tested with actually do warn,
> but I'm inclined to leave things as-is: some people will get warnings
> and that's probably worse than a couple of bytes bloat in befs.
> 
> It shouldn't cause any bloat, really.  We have the "uninitialized_var"
> macro which avoids any bloat and is self-documenting.  And the nice
> thing about self-documenting code is that it prevents Andrew from
> having to explain strange code to Luis ;)  But unintialized_var in
> unpopular for reasons which I personally find unpersuasive, given
> the advantages...
> 

I understand. Let's keep the code as it is.

Not worth adding uninitialized_var() for that declaration. Even though they
are self-documenting indeed.

Is this also the case with the node_off declaration?
Before being passed by reference to befs_btree_seekleaf() the initial value
is overwritten with node_off = bt_super.root_node_ptr;

Thanks for reviewing this,
Luis

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

end of thread, other threads:[~2016-06-01 23:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-30  0:39 [PATCH] befs/btree: remove unneeded initializations Luis de Bethencourt
2016-06-01 22:42 ` Andrew Morton
2016-06-01 23:43   ` 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;
as well as URLs for NNTP newsgroup(s).