* [PATCHv2 0/6] Endian bugfixes
@ 2012-03-12 10:13 Andrei Emeltchenko
2012-03-12 10:13 ` [PATCHv2 1/6] Bluetooth: Correct ediv in SMP Andrei Emeltchenko
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Those patches fix bugs and typos related to endian
conversion reported by sparse.
Changes:
* v2: Use __constant version with constants.
Andrei Emeltchenko (6):
Bluetooth: Correct ediv in SMP
Bluetooth: Correct length calc in L2CAP conf rsp
Bluetooth: Correct CID endian notation
Bluetooth: Convert error codes to le16
Bluetooth: trivial: Fix endian conversion mode
Bluetooth: mgmt: Add missing endian conversion
include/net/bluetooth/smp.h | 2 +-
net/bluetooth/l2cap_core.c | 18 +++++++++---------
net/bluetooth/mgmt.c | 11 ++++++++---
net/bluetooth/smp.c | 2 +-
4 files changed, 19 insertions(+), 14 deletions(-)
--
1.7.9
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCHv2 1/6] Bluetooth: Correct ediv in SMP
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
@ 2012-03-12 10:13 ` Andrei Emeltchenko
2012-03-12 17:44 ` Marcel Holtmann
2012-03-16 15:34 ` Johan Hedberg
2012-03-12 10:13 ` [PATCHv2 2/6] Bluetooth: Correct length calc in L2CAP conf rsp Andrei Emeltchenko
` (4 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/smp.h | 2 +-
net/bluetooth/smp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h
index 7b3acdd..ca356a7 100644
--- a/include/net/bluetooth/smp.h
+++ b/include/net/bluetooth/smp.h
@@ -77,7 +77,7 @@ struct smp_cmd_encrypt_info {
#define SMP_CMD_MASTER_IDENT 0x07
struct smp_cmd_master_ident {
- __u16 ediv;
+ __le16 ediv;
__u8 rand[8];
} __packed;
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index deb1198..6fc7c47 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -956,7 +956,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
HCI_SMP_LTK_SLAVE, 1, authenticated,
enc.ltk, smp->enc_key_size, ediv, ident.rand);
- ident.ediv = cpu_to_le16(ediv);
+ ident.ediv = ediv;
smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident);
--
1.7.9
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCHv2 2/6] Bluetooth: Correct length calc in L2CAP conf rsp
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
2012-03-12 10:13 ` [PATCHv2 1/6] Bluetooth: Correct ediv in SMP Andrei Emeltchenko
@ 2012-03-12 10:13 ` Andrei Emeltchenko
2012-03-12 17:43 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 3/6] Bluetooth: Correct CID endian notation Andrei Emeltchenko
` (3 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
cmd->len is in le format so convert it to host format before use.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0eca14d..85c3404 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2955,14 +2955,14 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data;
u16 scid, flags, result;
struct l2cap_chan *chan;
- int len = cmd->len - sizeof(*rsp);
+ int len = le16_to_cpu(cmd->len) - sizeof(*rsp);
scid = __le16_to_cpu(rsp->scid);
flags = __le16_to_cpu(rsp->flags);
result = __le16_to_cpu(rsp->result);
- BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x",
- scid, flags, result);
+ BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x len %d",
+ scid, flags, result, len);
chan = l2cap_get_chan_by_scid(conn, scid);
if (!chan)
--
1.7.9
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCHv2 3/6] Bluetooth: Correct CID endian notation
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
2012-03-12 10:13 ` [PATCHv2 1/6] Bluetooth: Correct ediv in SMP Andrei Emeltchenko
2012-03-12 10:13 ` [PATCHv2 2/6] Bluetooth: Correct length calc in L2CAP conf rsp Andrei Emeltchenko
@ 2012-03-12 10:13 ` Andrei Emeltchenko
2012-03-12 17:45 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 4/6] Bluetooth: Convert error codes to le16 Andrei Emeltchenko
` (2 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
L2CAP channel id is used in host format in internal L2CAP code.
Fix sparse warnings about wrong endian conversion.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 85c3404..c778585 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -834,7 +834,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
/* Find socket with cid and source bdaddr.
* Returns closest match, locked.
*/
-static struct l2cap_chan *l2cap_global_chan_by_scid(int state, __le16 cid, bdaddr_t *src)
+static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid, bdaddr_t *src)
{
struct l2cap_chan *c, *c1 = NULL;
@@ -4394,7 +4394,7 @@ drop:
return 0;
}
-static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct sk_buff *skb)
+static inline int l2cap_att_channel(struct l2cap_conn *conn, u16 cid, struct sk_buff *skb)
{
struct l2cap_chan *chan;
--
1.7.9
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCHv2 4/6] Bluetooth: Convert error codes to le16
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
` (2 preceding siblings ...)
2012-03-12 10:13 ` [PATCHv2 3/6] Bluetooth: Correct CID endian notation Andrei Emeltchenko
@ 2012-03-12 10:13 ` Andrei Emeltchenko
2012-03-12 17:46 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 5/6] Bluetooth: trivial: Fix endian conversion mode Andrei Emeltchenko
2012-03-12 10:13 ` [PATCHv2 6/6] Bluetooth: mgmt: Add missing endian conversion Andrei Emeltchenko
5 siblings, 1 reply; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Create Chan Rsp shall put result and status in le format.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c778585..57c8507 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3263,8 +3263,8 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
/* Placeholder: Always reject */
rsp.dcid = 0;
rsp.scid = cpu_to_le16(scid);
- rsp.result = L2CAP_CR_NO_MEM;
- rsp.status = L2CAP_CS_NO_INFO;
+ rsp.result = __constant_cpu_to_le16(L2CAP_CR_NO_MEM);
+ rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP,
sizeof(rsp), &rsp);
--
1.7.9
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCHv2 5/6] Bluetooth: trivial: Fix endian conversion mode
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
` (3 preceding siblings ...)
2012-03-12 10:13 ` [PATCHv2 4/6] Bluetooth: Convert error codes to le16 Andrei Emeltchenko
@ 2012-03-12 10:13 ` Andrei Emeltchenko
2012-03-12 17:47 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 6/6] Bluetooth: mgmt: Add missing endian conversion Andrei Emeltchenko
5 siblings, 1 reply; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
In L2CAP we use le16 format so change direction of conversion
from le16_to_cpu to cpu_to_le16.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 57c8507..8598489 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2376,9 +2376,9 @@ done:
chan->remote_mps = size;
rfc.retrans_timeout =
- le16_to_cpu(L2CAP_DEFAULT_RETRANS_TO);
+ __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO);
rfc.monitor_timeout =
- le16_to_cpu(L2CAP_DEFAULT_MONITOR_TO);
+ __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO);
set_bit(CONF_MODE_DONE, &chan->conf_state);
--
1.7.9
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCHv2 6/6] Bluetooth: mgmt: Add missing endian conversion
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
` (4 preceding siblings ...)
2012-03-12 10:13 ` [PATCHv2 5/6] Bluetooth: trivial: Fix endian conversion mode Andrei Emeltchenko
@ 2012-03-12 10:13 ` Andrei Emeltchenko
2012-03-12 17:47 ` Marcel Holtmann
5 siblings, 1 reply; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-03-12 10:13 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add missing endian conversion for page scan interval and window.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/mgmt.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 97b5b6c..06b5df3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2523,13 +2523,18 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
if (cp->val) {
type = PAGE_SCAN_TYPE_INTERLACED;
- acp.interval = 0x0024; /* 22.5 msec page scan interval */
+
+ /* 22.5 msec page scan interval */
+ acp.interval = __constant_cpu_to_le16(0x0024);
} else {
type = PAGE_SCAN_TYPE_STANDARD; /* default */
- acp.interval = 0x0800; /* default 1.28 sec page scan */
+
+ /* default 1.28 sec page scan */
+ acp.interval = __constant_cpu_to_le16(0x0800);
}
- acp.window = 0x0012; /* default 11.25 msec page scan window */
+ /* default 11.25 msec page scan window */
+ acp.window = __constant_cpu_to_le16(0x0012);
err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp),
&acp);
--
1.7.9
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCHv2 2/6] Bluetooth: Correct length calc in L2CAP conf rsp
2012-03-12 10:13 ` [PATCHv2 2/6] Bluetooth: Correct length calc in L2CAP conf rsp Andrei Emeltchenko
@ 2012-03-12 17:43 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2012-03-12 17:43 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> cmd->len is in le format so convert it to host format before use.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2 1/6] Bluetooth: Correct ediv in SMP
2012-03-12 10:13 ` [PATCHv2 1/6] Bluetooth: Correct ediv in SMP Andrei Emeltchenko
@ 2012-03-12 17:44 ` Marcel Holtmann
2012-03-16 15:34 ` Johan Hedberg
1 sibling, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2012-03-12 17:44 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> include/net/bluetooth/smp.h | 2 +-
> net/bluetooth/smp.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2 3/6] Bluetooth: Correct CID endian notation
2012-03-12 10:13 ` [PATCHv2 3/6] Bluetooth: Correct CID endian notation Andrei Emeltchenko
@ 2012-03-12 17:45 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2012-03-12 17:45 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> L2CAP channel id is used in host format in internal L2CAP code.
> Fix sparse warnings about wrong endian conversion.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 85c3404..c778585 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -834,7 +834,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
> /* Find socket with cid and source bdaddr.
> * Returns closest match, locked.
> */
> -static struct l2cap_chan *l2cap_global_chan_by_scid(int state, __le16 cid, bdaddr_t *src)
> +static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid, bdaddr_t *src)
I get the feeling we are turning in circles here. Can you please have a
second look that all the conversions are now correct.
And yes, we wanna store the CID in host endian, while it is provided in
little endian by userspace.
Regards
Marcel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2 4/6] Bluetooth: Convert error codes to le16
2012-03-12 10:13 ` [PATCHv2 4/6] Bluetooth: Convert error codes to le16 Andrei Emeltchenko
@ 2012-03-12 17:46 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2012-03-12 17:46 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> Create Chan Rsp shall put result and status in le format.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2 5/6] Bluetooth: trivial: Fix endian conversion mode
2012-03-12 10:13 ` [PATCHv2 5/6] Bluetooth: trivial: Fix endian conversion mode Andrei Emeltchenko
@ 2012-03-12 17:47 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2012-03-12 17:47 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> In L2CAP we use le16 format so change direction of conversion
> from le16_to_cpu to cpu_to_le16.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2 6/6] Bluetooth: mgmt: Add missing endian conversion
2012-03-12 10:13 ` [PATCHv2 6/6] Bluetooth: mgmt: Add missing endian conversion Andrei Emeltchenko
@ 2012-03-12 17:47 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2012-03-12 17:47 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
> Add missing endian conversion for page scan interval and window.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/mgmt.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2 1/6] Bluetooth: Correct ediv in SMP
2012-03-12 10:13 ` [PATCHv2 1/6] Bluetooth: Correct ediv in SMP Andrei Emeltchenko
2012-03-12 17:44 ` Marcel Holtmann
@ 2012-03-16 15:34 ` Johan Hedberg
1 sibling, 0 replies; 14+ messages in thread
From: Johan Hedberg @ 2012-03-16 15:34 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
On Mon, Mar 12, 2012, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> include/net/bluetooth/smp.h | 2 +-
> net/bluetooth/smp.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
All patches in this set have been applied to my bluetooth-next tree. I
also checked patch 3/6 (which Marcel had doubts about) and concluded
that it was correct.
Johan
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-03-16 15:34 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-12 10:13 [PATCHv2 0/6] Endian bugfixes Andrei Emeltchenko
2012-03-12 10:13 ` [PATCHv2 1/6] Bluetooth: Correct ediv in SMP Andrei Emeltchenko
2012-03-12 17:44 ` Marcel Holtmann
2012-03-16 15:34 ` Johan Hedberg
2012-03-12 10:13 ` [PATCHv2 2/6] Bluetooth: Correct length calc in L2CAP conf rsp Andrei Emeltchenko
2012-03-12 17:43 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 3/6] Bluetooth: Correct CID endian notation Andrei Emeltchenko
2012-03-12 17:45 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 4/6] Bluetooth: Convert error codes to le16 Andrei Emeltchenko
2012-03-12 17:46 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 5/6] Bluetooth: trivial: Fix endian conversion mode Andrei Emeltchenko
2012-03-12 17:47 ` Marcel Holtmann
2012-03-12 10:13 ` [PATCHv2 6/6] Bluetooth: mgmt: Add missing endian conversion Andrei Emeltchenko
2012-03-12 17:47 ` Marcel Holtmann
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).