Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] tools/btsnoop : Fix variable reassigning issue
@ 2014-09-10  6:35 gowtham babu
  2014-09-12 16:51 ` Johan Hedberg
  0 siblings, 1 reply; 3+ messages in thread
From: gowtham babu @ 2014-09-10  6:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs, gowtham babu

The Variable 'written' is reassigned a value before the old one has been used.
The below on fix the same.
---
 tools/btsnoop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/btsnoop.c b/tools/btsnoop.c
index 6ca62d2..86f4691 100644
--- a/tools/btsnoop.c
+++ b/tools/btsnoop.c
@@ -211,7 +211,7 @@ next_packet:
 		goto next_packet;
 	}
 
-	written = input_pkt[select_input].size = htobe32(toread - 1);
+	input_pkt[select_input].size = htobe32(toread - 1);
 	written = input_pkt[select_input].len = htobe32(toread - 1);
 
 	switch (buf[0]) {
-- 
1.9.1


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

* Re: [PATCH 1/2] tools/btsnoop : Fix variable reassigning issue
  2014-09-10  6:35 [PATCH 1/2] tools/btsnoop : Fix variable reassigning issue gowtham babu
@ 2014-09-12 16:51 ` Johan Hedberg
  2014-09-15  6:15   ` Gowtham Anandha Babu
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2014-09-12 16:51 UTC (permalink / raw)
  To: gowtham babu; +Cc: linux-bluetooth, bharat.panda, cpgs

Hi,

On Wed, Sep 10, 2014, gowtham babu wrote:
> The Variable 'written' is reassigned a value before the old one has been used.
> The below on fix the same.
> ---
>  tools/btsnoop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/btsnoop.c b/tools/btsnoop.c
> index 6ca62d2..86f4691 100644
> --- a/tools/btsnoop.c
> +++ b/tools/btsnoop.c
> @@ -211,7 +211,7 @@ next_packet:
>  		goto next_packet;
>  	}
>  
> -	written = input_pkt[select_input].size = htobe32(toread - 1);
> +	input_pkt[select_input].size = htobe32(toread - 1);
>  	written = input_pkt[select_input].len = htobe32(toread - 1);

Why is there a need to evaluate htobe32(toread - 1) twice here? Why not
avoid that by something like:

	written = htobe32(toread - 1);
	input_pkt[select_input].size = written;
	input_pkt[select_input].len  = written;

Johan

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

* RE: [PATCH 1/2] tools/btsnoop : Fix variable reassigning issue
  2014-09-12 16:51 ` Johan Hedberg
@ 2014-09-15  6:15   ` Gowtham Anandha Babu
  0 siblings, 0 replies; 3+ messages in thread
From: Gowtham Anandha Babu @ 2014-09-15  6:15 UTC (permalink / raw)
  To: 'Johan Hedberg'; +Cc: linux-bluetooth, bharat.panda, cpgs

Hi,

> -----Original Message-----
> From: Johan Hedberg [mailto:johan.hedberg@gmail.com]
> Sent: Friday, September 12, 2014 10:22 PM
> To: gowtham babu
> Cc: linux-bluetooth@vger.kernel.org; bharat.panda@samsung.com;
> cpgs@samsung.com
> Subject: Re: [PATCH 1/2] tools/btsnoop : Fix variable reassigning issue
> 
> Hi,
> 
> On Wed, Sep 10, 2014, gowtham babu wrote:
> > The Variable 'written' is reassigned a value before the old one has been
> used.
> > The below on fix the same.
> > ---
> >  tools/btsnoop.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/btsnoop.c b/tools/btsnoop.c index 6ca62d2..86f4691
> > 100644
> > --- a/tools/btsnoop.c
> > +++ b/tools/btsnoop.c
> > @@ -211,7 +211,7 @@ next_packet:
> >  		goto next_packet;
> >  	}
> >
> > -	written = input_pkt[select_input].size = htobe32(toread - 1);
> > +	input_pkt[select_input].size = htobe32(toread - 1);
> >  	written = input_pkt[select_input].len = htobe32(toread - 1);
> 
> Why is there a need to evaluate htobe32(toread - 1) twice here? Why not
> avoid that by something like:
> 
> 	written = htobe32(toread - 1);
> 	input_pkt[select_input].size = written;
> 	input_pkt[select_input].len  = written;
> 
> Johan


I had fixed this and sent the revised patch. Please have a look at it.

Regards,
Gowtham


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

end of thread, other threads:[~2014-09-15  6:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-10  6:35 [PATCH 1/2] tools/btsnoop : Fix variable reassigning issue gowtham babu
2014-09-12 16:51 ` Johan Hedberg
2014-09-15  6:15   ` Gowtham Anandha Babu

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