linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Fix strict aliasing issue
@ 2011-03-23 12:11 Rafal Michalski
  2011-03-23 13:17 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Rafal Michalski @ 2011-03-23 12:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Rafal Michalski

This patch changes type of "pending" flag to uint32_t type.
Pointer to this flag is passed to hci_clear_bit function as void * and
then casted to uint32_t * again. Previously unsigned long type made some
unexpected performance which occured after violating strict aliasing
rule. This patch fixes this problem and this solution is much easier than
solution of changing types of many object (from uint32_t to unsigned long,
including changing type for castng in hci_*_bit function family), which
is overcomplicated. Also, not all objects can be changed, like
hci_dev_info struct, since it is violating compatibility rules between
kernel and user spaces.
---
 plugins/hciops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index 4225cd8..69627eb 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -111,7 +111,7 @@ static struct dev_info {
 	uint16_t did_version;
 
 	gboolean up;
-	unsigned long pending;
+	uint32_t pending;
 
 	GIOChannel *io;
 	guint watch_id;
-- 
1.6.3.3


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

* Re: [PATCH v2] Fix strict aliasing issue
  2011-03-23 12:11 [PATCH v2] Fix strict aliasing issue Rafal Michalski
@ 2011-03-23 13:17 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-03-23 13:17 UTC (permalink / raw)
  To: Rafal Michalski; +Cc: linux-bluetooth

Hi Rafal,

On Wed, Mar 23, 2011, Rafal Michalski wrote:
> This patch changes type of "pending" flag to uint32_t type.
> Pointer to this flag is passed to hci_clear_bit function as void * and
> then casted to uint32_t * again. Previously unsigned long type made some
> unexpected performance which occured after violating strict aliasing
> rule. This patch fixes this problem and this solution is much easier than
> solution of changing types of many object (from uint32_t to unsigned long,
> including changing type for castng in hci_*_bit function family), which
> is overcomplicated. Also, not all objects can be changed, like
> hci_dev_info struct, since it is violating compatibility rules between
> kernel and user spaces.
> ---
>  plugins/hciops.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks. The patch has been pushed upstream after I did some heavy
cleanup on the commit message for it to be more readable :)

Johan

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

end of thread, other threads:[~2011-03-23 13:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-23 12:11 [PATCH v2] Fix strict aliasing issue Rafal Michalski
2011-03-23 13:17 ` Johan Hedberg

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