Bluetooth: Remove unnecessary 'send' parameter from smp_failure()
Subsystems (2)
PATCH 1/1 Bluetooth: Remove unnecessary 'send' parameter from smp_failure()
From: Johan Hedberg <[email protected]>
The send parameter has only been used for determining whether to send a Pairing Failed PDU or not. However, the function can equally well use the already existing reason parameter to make this choice and send the PDU whenever a non-zero value was passed.
--- net/bluetooth/smp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/bluetooth/smp.c +8 -8
@@ -257,11 +257,11 @@ static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size)return 0 ; } -static void smp_failure (struct l2cap_conn *conn,u8 reason,u8 send) +static void smp_failure (struct l2cap_conn *conn,u8 reason) {struct hci_conn *hcon = conn->hcon; -if (send) +if (reason)smp_send_cmd (conn,SMP_CMD_PAIRING_FAIL ,sizeof (reason), &reason);
@@ -406,7 +406,7 @@ static void confirm_work(struct work_struct *work)return ; error: -smp_failure (conn, reason,1 ); +smp_failure (conn, reason); }static void random_work (struct work_struct *work)
@@ -490,7 +490,7 @@ static void random_work(struct work_struct *work)return ; error: -smp_failure (conn, reason,1 ); +smp_failure (conn, reason); }static struct smp_chan *smp_chan_create (struct l2cap_conn *conn)
@@ -555,10 +555,10 @@ int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey)break ;case MGMT_OP_USER_PASSKEY_NEG_REPLY :case MGMT_OP_USER_CONFIRM_NEG_REPLY : -smp_failure (conn,SMP_PASSKEY_ENTRY_FAILED ,1 ); +smp_failure (conn,SMP_PASSKEY_ENTRY_FAILED );return 0 ;default : -smp_failure (conn,SMP_PASSKEY_ENTRY_FAILED ,1 ); +smp_failure (conn,SMP_PASSKEY_ENTRY_FAILED );return -EOPNOTSUPP ; }
@@ -895,7 +895,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)break ;case SMP_CMD_PAIRING_FAIL : -smp_failure (conn, skb->data[0 ],0 ); +smp_failure (conn,0 ); reason =0 ; err = -EPERM ;break ;
@@ -941,7 +941,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) done:if (reason) -smp_failure (conn, reason,1 ); +smp_failure (conn, reason);kfree_skb (skb);return err;
Signature · 1 line
1.8.3.1
Hi Johan,
net/bluetooth/smp.c int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) · line 898
Quoted 6 lines · On Wed, Nov 6, 2013 at 5:24 AM, <[email protected]> wrote:
net/bluetooth/smp.c +1
-1@@ -895,7 +895,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)break ;case SMP_CMD_PAIRING_FAIL : -smp_failure (conn, skb->data[0 ],0 ); +smp_failure (conn,0 );
I think you meant "smp_failure(conn, skb->data[0]);" here.
net/bluetooth/smp.c int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) · line 901
Quoted 3 lines
net/bluetooth/smp.c +0
-0reason =0 ; err = -EPERM ;break ;
Best Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Hi again,
Quoted 4 lines · Anderson Lizardo
Hi Johan,
On Wed, Nov 6, 2013 at 5:24 AM, <[email protected]> wrote:
Quoted 8 lines
net/bluetooth/smp.c int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) · line 898
Quoted 6 lines
net/bluetooth/smp.c +1
-1@@ -895,7 +895,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)break ;case SMP_CMD_PAIRING_FAIL : -smp_failure (conn, skb->data[0 ],0 ); +smp_failure (conn,0 );I think you meant "
smp_failure(conn, skb->data[0]);" here.
My bad, I see now that the purpose is to not send an error in this case.
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Hi Lizardo,
Quoted 9 lines · Anderson Lizardo
Quoted 7 lines · Anderson Lizardo
Hi Johan,
Quoted 3 lines · On Wed, Nov 6, 2013 at 5:24 AM, <[email protected]> wrote:
(quoted diff) +0
-0@@ -895,7 +895,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) break;
Quoted 7 lines
Quoted 5 lines
net/bluetooth/smp.c int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) · line 898
Quoted 3 lines
net/bluetooth/smp.c +1
-1case SMP_CMD_PAIRING_FAIL : -smp_failure (conn, skb->data[0 ],0 ); +smp_failure (conn,0 );I think you meant "
smp_failure(conn, skb->data[0]);" here.My bad, I see now that the purpose is to not send an error in this case.
Exactly. Which is why the original code was misleading in that you might have thought it actually did something with skb->data[0].
Johan
Marcel Holtmann
maintainerHi Johan,
Quoted 9 lines
The send parameter has only been used for determining whether to send a Pairing Failed PDU or not. However, the function can equally well use the already existing reason parameter to make this choice and send the PDU whenever a non-zero value was passed.
Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/smp.c| 16 ++++++++--------1 file changed, 8 insertions(+), 8 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel