linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Silence sparse warning
@ 2012-03-19 11:26 Andrei Emeltchenko
  2012-03-19 17:39 ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Andrei Emeltchenko @ 2012-03-19 11:26 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Silence sparse warning by introducing tmp __le variable. Despite being
short constructions like "val = le32_to_cpu(val)" are sources of
unneeded warnings (shown below)
...
net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/mgmt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b8f9016..eb8cb66 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -435,6 +435,7 @@ static u8 bluetooth_base_uuid[] = {
 
 static u16 get_uuid16(u8 *uuid128)
 {
+	__le32 tmp;
 	u32 val;
 	int i;
 
@@ -443,9 +444,9 @@ static u16 get_uuid16(u8 *uuid128)
 			return 0;
 	}
 
-	memcpy(&val, &uuid128[12], 4);
+	memcpy(&tmp, &uuid128[12], 4);
 
-	val = le32_to_cpu(val);
+	val = le32_to_cpu(tmp);
 	if (val > 0xffff)
 		return 0;
 
-- 
1.7.9.1


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

* Re: [PATCH] Bluetooth: Silence sparse warning
  2012-03-19 11:26 Andrei Emeltchenko
@ 2012-03-19 17:39 ` Marcel Holtmann
  2012-03-20  8:34   ` Andrei Emeltchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2012-03-19 17:39 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> Silence sparse warning by introducing tmp __le variable. Despite being
> short constructions like "val = le32_to_cpu(val)" are sources of
> unneeded warnings (shown below)
> ...
> net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
> ...
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/mgmt.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index b8f9016..eb8cb66 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -435,6 +435,7 @@ static u8 bluetooth_base_uuid[] = {
>  
>  static u16 get_uuid16(u8 *uuid128)
>  {
> +	__le32 tmp;
>  	u32 val;
>  	int i;
>  
> @@ -443,9 +444,9 @@ static u16 get_uuid16(u8 *uuid128)
>  			return 0;
>  	}
>  
> -	memcpy(&val, &uuid128[12], 4);
> +	memcpy(&tmp, &uuid128[12], 4);
>  
> -	val = le32_to_cpu(val);
> +	val = le32_to_cpu(tmp);

why aren't we using get_unaligned_le32?

Regards

Marcel



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

* [PATCH] Bluetooth: Silence sparse warning
@ 2012-03-20  8:32 Andrei Emeltchenko
  2012-03-20 13:19 ` Gustavo Padovan
  2012-03-20 15:49 ` Marcel Holtmann
  0 siblings, 2 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2012-03-20  8:32 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Silence sparse warning shown below:
...
net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/mgmt.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b8f9016..d93f2bf 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -443,9 +443,7 @@ static u16 get_uuid16(u8 *uuid128)
 			return 0;
 	}
 
-	memcpy(&val, &uuid128[12], 4);
-
-	val = le32_to_cpu(val);
+	val = get_unaligned_le32(&uuid128[12]);
 	if (val > 0xffff)
 		return 0;
 
-- 
1.7.9.1


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

* Re: [PATCH] Bluetooth: Silence sparse warning
  2012-03-19 17:39 ` Marcel Holtmann
@ 2012-03-20  8:34   ` Andrei Emeltchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2012-03-20  8:34 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Mon, Mar 19, 2012 at 10:39:20AM -0700, Marcel Holtmann wrote:
> > -	memcpy(&val, &uuid128[12], 4);
> > +	memcpy(&tmp, &uuid128[12], 4);
> >  
> > -	val = le32_to_cpu(val);
> > +	val = le32_to_cpu(tmp);
> 
> why aren't we using get_unaligned_le32?

You are right here, just sent new version.

Best regards 
Andrei Emeltchenko 

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

* Re: [PATCH] Bluetooth: Silence sparse warning
  2012-03-20  8:32 [PATCH] Bluetooth: Silence sparse warning Andrei Emeltchenko
@ 2012-03-20 13:19 ` Gustavo Padovan
  2012-03-20 15:49 ` Marcel Holtmann
  1 sibling, 0 replies; 9+ messages in thread
From: Gustavo Padovan @ 2012-03-20 13:19 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-03-20 10:32:25 +0200]:

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Silence sparse warning shown below:
> ...
> net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
> ...
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/mgmt.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index b8f9016..d93f2bf 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -443,9 +443,7 @@ static u16 get_uuid16(u8 *uuid128)
>  			return 0;
>  	}
>  
> -	memcpy(&val, &uuid128[12], 4);
> -
> -	val = le32_to_cpu(val);
> +	val = get_unaligned_le32(&uuid128[12]);
>  	if (val > 0xffff)
>  		return 0;

Patch is applied. Thanks.

Btw, this is the last change in maintainership (until we get the shared tree).
I solved all my internet problems (I was a bit offline last week) and then I'm
back to this task. Sorry for the inconvenience, won't happen again.

	Gustavo

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

* Re: [PATCH] Bluetooth: Silence sparse warning
  2012-03-20  8:32 [PATCH] Bluetooth: Silence sparse warning Andrei Emeltchenko
  2012-03-20 13:19 ` Gustavo Padovan
@ 2012-03-20 15:49 ` Marcel Holtmann
  1 sibling, 0 replies; 9+ messages in thread
From: Marcel Holtmann @ 2012-03-20 15:49 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> Silence sparse warning shown below:
> ...
> net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
> ...
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/mgmt.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index b8f9016..d93f2bf 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -443,9 +443,7 @@ static u16 get_uuid16(u8 *uuid128)
>  			return 0;
>  	}
>  
> -	memcpy(&val, &uuid128[12], 4);
> -
> -	val = le32_to_cpu(val);
> +	val = get_unaligned_le32(&uuid128[12]);

I actually prefer get_unaligned_le32(uuid128 + 12) in these cases.

Regards

Marcel



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

* [PATCH] Bluetooth: Silence sparse warning
@ 2012-03-20 16:08 Andrei Emeltchenko
  2012-03-20 16:18 ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Andrei Emeltchenko @ 2012-03-20 16:08 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Silence sparse warning shown below:
...
net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/mgmt.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b8f9016..913c6d2 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -443,9 +443,7 @@ static u16 get_uuid16(u8 *uuid128)
 			return 0;
 	}
 
-	memcpy(&val, &uuid128[12], 4);
-
-	val = le32_to_cpu(val);
+	val = get_unaligned_le32(uuid128 + 12);
 	if (val > 0xffff)
 		return 0;
 
-- 
1.7.9.1


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

* Re: [PATCH] Bluetooth: Silence sparse warning
  2012-03-20 16:08 Andrei Emeltchenko
@ 2012-03-20 16:18 ` Marcel Holtmann
  2012-03-20 16:24   ` Andrei Emeltchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2012-03-20 16:18 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> Silence sparse warning shown below:
> ...
> net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
> ...
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/mgmt.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index b8f9016..913c6d2 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -443,9 +443,7 @@ static u16 get_uuid16(u8 *uuid128)
>  			return 0;
>  	}
>  
> -	memcpy(&val, &uuid128[12], 4);
> -
> -	val = le32_to_cpu(val);
> +	val = get_unaligned_le32(uuid128 + 12);
>  	if (val > 0xffff)
>  		return 0;
>  

since Gustavo already applied this patch, don't bother ;)

Regards

Marcel



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

* Re: [PATCH] Bluetooth: Silence sparse warning
  2012-03-20 16:18 ` Marcel Holtmann
@ 2012-03-20 16:24   ` Andrei Emeltchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2012-03-20 16:24 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Tue, Mar 20, 2012 at 09:18:27AM -0700, Marcel Holtmann wrote:
> >  
> > -	memcpy(&val, &uuid128[12], 4);
> > -
> > -	val = le32_to_cpu(val);
> > +	val = get_unaligned_le32(uuid128 + 12);
> >  	if (val > 0xffff)
> >  		return 0;
> >  
> 
> since Gustavo already applied this patch, don't bother ;)

It was not pushed when I sent updated version.

Best regards 
Andrei Emeltchenko 


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

end of thread, other threads:[~2012-03-20 16:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-20  8:32 [PATCH] Bluetooth: Silence sparse warning Andrei Emeltchenko
2012-03-20 13:19 ` Gustavo Padovan
2012-03-20 15:49 ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2012-03-20 16:08 Andrei Emeltchenko
2012-03-20 16:18 ` Marcel Holtmann
2012-03-20 16:24   ` Andrei Emeltchenko
2012-03-19 11:26 Andrei Emeltchenko
2012-03-19 17:39 ` Marcel Holtmann
2012-03-20  8:34   ` Andrei Emeltchenko

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).