Skip to contentSkip to conversation

Bluetooth: Simplify / fix return values from tk_request

PATCH In review Guenter Roeck 4 participants 13 messages Apr 3, 2020 – Apr 7, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Simplify / fix return values from tk_request

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +4 -5
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
 	struct l2cap_chan *chan = conn->smp;
 	struct smp_chan *smp = chan->data;
 	u32 passkey = 0;
-	int ret = 0;
-	int err;
+	int ret;
 
 	/* Initialize key for JUST WORKS */
 	memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
 	/* If Just Works, Continue with Zero TK and ask user-space for
 	 * confirmation */
 	if (smp->method == JUST_WORKS) {
-		err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+		ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
 						hcon->type,
 						hcon->dst_type,
 						passkey, 1);
-		if (err)
-			return SMP_UNSPECIFIED;
+		if (ret)
+			return ret;
 		set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
 		return 0;
 	}
Signature · 1 line
2.17.1
#1 lore raw

Hi Guenter/Marcel,

Quoted 38 lines · Guenter Roeck

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +1 -2
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        struct l2cap_chan *chan = conn->smp;
        struct smp_chan *smp = chan->data;
        u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
        /* Initialize key for JUST WORKS */
        memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        /* If Just Works, Continue with Zero TK and ask user-space for
         * confirmation */

net/bluetooth/smp.c static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, · line 894

Quoted 10 lines
net/bluetooth/smp.c +3 -3
        if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                                hcon->type,
                                                hcon->dst_type,
                                                passkey, 1);
-               if (err)
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;

I think there may be some miss match between expected types of error codes here. The SMP error code type seems to be expected throughout this code base, so this change would propagate a potential negative value while the rest of the SMP protocol expects strictly positive error codes.

Quoted 6 lines
net/bluetooth/smp.c +0 -1
                set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
                return 0;
        }
--

2.17.1

Thanks,
Alain

#2 lore raw
Quoted 49 lines · Alain Michaud

Hi Guenter/Marcel,

Quoted 45 lines · Guenter Roeck

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +2 -4
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        struct l2cap_chan *chan = conn->smp;
        struct smp_chan *smp = chan->data;
        u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
        /* Initialize key for JUST WORKS */
        memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        /* If Just Works, Continue with Zero TK and ask user-space for
         * confirmation */
        if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                                hcon->type,
                                                hcon->dst_type,
                                                passkey, 1);
-               if (err)
Quoted 9 lines

net/bluetooth/smp.c static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, · line 894

Quoted 3 lines
net/bluetooth/smp.c +2 -1
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;

I think there may be some miss match between expected types of error codes here. The SMP error code type seems to be expected throughout this code base, so this change would propagate a potential negative value while the rest of the SMP protocol expects strictly positive error codes.

Up to the patch introducing the SMP_UNSPECIFIED return value, tk_request() returned negative error codes, and all callers convert it to SMP_UNSPECIFIED.

If tk_request() is supposed to return SMP_UNSPECIFIED on error, it should be returned consistently, and its callers don't have to convert it again.

Guenter

Quoted 10 lines
Quoted 6 lines
net/bluetooth/smp.c +0 -1
                set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
                return 0;
        }
--

2.17.1

Thanks,
Alain

#3 lore raw
Quoted 61 lines · Guenter Roeck
Quoted 49 lines · Alain Michaud

Hi Guenter/Marcel,

Quoted 45 lines · Guenter Roeck

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +2 -4
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        struct l2cap_chan *chan = conn->smp;
        struct smp_chan *smp = chan->data;
        u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
        /* Initialize key for JUST WORKS */
        memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        /* If Just Works, Continue with Zero TK and ask user-space for
         * confirmation */
        if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                                hcon->type,
                                                hcon->dst_type,
                                                passkey, 1);
-               if (err)
Quoted 9 lines

net/bluetooth/smp.c static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, · line 894

Quoted 3 lines
net/bluetooth/smp.c +2 -1
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;

I think there may be some miss match between expected types of error codes here. The SMP error code type seems to be expected throughout this code base, so this change would propagate a potential negative value while the rest of the SMP protocol expects strictly positive error codes.

Quoted 5 lines

Up to the patch introducing the SMP_UNSPECIFIED return value, tk_request() returned negative error codes, and all callers convert it to SMP_UNSPECIFIED.

If tk_request() is supposed to return SMP_UNSPECIFIED on error, it should be returned consistently, and its callers don't have to convert it again.

Agreed, the conventions aren't clear here. I'll differ to Marcel to provide guidance in this case where as a long term solution might increase the scope of this patch beyond what would be reasonable.

Quoted 14 lines

Guenter

Quoted 10 lines
Quoted 6 lines
net/bluetooth/smp.c +0 -1
                set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
                return 0;
        }
--

2.17.1

Thanks,
Alain

#4 lore raw

The patch looks good to me. Agreed with Guenter's assessment, I made a mistake in the original patch by not being consistent with the function contract.

Quoted 85 lines · Alain Michaud
Quoted 61 lines · Guenter Roeck
Quoted 49 lines · Alain Michaud

Hi Guenter/Marcel,

Quoted 45 lines · Guenter Roeck

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +2 -4
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        struct l2cap_chan *chan = conn->smp;
        struct smp_chan *smp = chan->data;
        u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
        /* Initialize key for JUST WORKS */
        memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        /* If Just Works, Continue with Zero TK and ask user-space for
         * confirmation */
        if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                                hcon->type,
                                                hcon->dst_type,
                                                passkey, 1);
-               if (err)
Quoted 9 lines

net/bluetooth/smp.c static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, · line 894

Quoted 3 lines
net/bluetooth/smp.c +2 -1
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;

I think there may be some miss match between expected types of error codes here. The SMP error code type seems to be expected throughout this code base, so this change would propagate a potential negative value while the rest of the SMP protocol expects strictly positive error codes.

Quoted 5 lines

Up to the patch introducing the SMP_UNSPECIFIED return value, tk_request() returned negative error codes, and all callers convert it to SMP_UNSPECIFIED.

If tk_request() is supposed to return SMP_UNSPECIFIED on error, it should be returned consistently, and its callers don't have to convert it again.

Agreed, the conventions aren't clear here. I'll differ to Marcel to provide guidance in this case where as a long term solution might increase the scope of this patch beyond what would be reasonable.

Quoted 14 lines

Guenter

Quoted 10 lines
Quoted 6 lines
net/bluetooth/smp.c +0 -1
                set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
                return 0;
        }
--

2.17.1

Thanks,
Alain

maintainer
#5 lore raw
In reply to Guenter Roeck

Hi Guenter,

Quoted 54 lines
Quoted 44 lines
Quoted 44 lines

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>

---
net/bluetooth/smp.c | 9 ++++-----

1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +2 -4
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
       struct l2cap_chan *chan = conn->smp;
       struct smp_chan *smp = chan->data;
       u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
       /* Initialize key for JUST WORKS */
       memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
       /* If Just Works, Continue with Zero TK and ask user-space for
        * confirmation */
       if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                               hcon->type,
                                               hcon->dst_type,
                                               passkey, 1);
-               if (err)
Quoted 9 lines

net/bluetooth/smp.c static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, · line 894

Quoted 3 lines
net/bluetooth/smp.c +2 -1
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;

I think there may be some miss match between expected types of error codes here. The SMP error code type seems to be expected throughout this code base, so this change would propagate a potential negative value while the rest of the SMP protocol expects strictly positive error codes.

Quoted 5 lines

Up to the patch introducing the SMP_UNSPECIFIED return value, tk_request() returned negative error codes, and all callers convert it to SMP_UNSPECIFIED.

If tk_request() is supposed to return SMP_UNSPECIFIED on error, it should be returned consistently, and its callers don't have to convert it again.

maybe we need to fix that initial patch then.

Regards

Marcel

#6 lore raw

Hi Marcel,

Can this patch be merged? Or do you prefer reverting the original patch and relanding it together with the fix?

Quoted 69 lines · Marcel Holtmann

Hi Guenter,

Quoted 54 lines
Quoted 44 lines
Quoted 44 lines

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>

---
net/bluetooth/smp.c | 9 ++++-----

1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +2 -4
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
       struct l2cap_chan *chan = conn->smp;
       struct smp_chan *smp = chan->data;
       u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
       /* Initialize key for JUST WORKS */
       memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
       /* If Just Works, Continue with Zero TK and ask user-space for
        * confirmation */
       if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                               hcon->type,
                                               hcon->dst_type,
                                               passkey, 1);
-               if (err)
Quoted 9 lines

net/bluetooth/smp.c static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, · line 894

Quoted 3 lines
net/bluetooth/smp.c +2 -1
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;

I think there may be some miss match between expected types of error codes here. The SMP error code type seems to be expected throughout this code base, so this change would propagate a potential negative value while the rest of the SMP protocol expects strictly positive error codes.

Quoted 5 lines

Up to the patch introducing the SMP_UNSPECIFIED return value, tk_request() returned negative error codes, and all callers convert it to SMP_UNSPECIFIED.

If tk_request() is supposed to return SMP_UNSPECIFIED on error, it should be returned consistently, and its callers don't have to convert it again.

maybe we need to fix that initial patch then.

Regards

Marcel

maintainer
#7 lore raw

Hi Sonny,

Quoted 2 lines

Can this patch be merged? Or do you prefer reverting the original patch and relanding it together with the fix?

since the original patch is already upstream, I need a patch with Fixes etc. And a Reviewed-By from you preferably.

Regards

Marcel

#8 lore raw
Quoted 7 lines · Marcel Holtmann

Hi Sonny,

Quoted 2 lines

Can this patch be merged? Or do you prefer reverting the original patch and relanding it together with the fix?

since the original patch is already upstream, I need a patch with Fixes etc. And a Reviewed-By from you preferably.

Isn't that what I sent with https://patchwork.kernel.org/patch/11472991/ ? What is missing (besides Sonny's Reviewed-by: tag) ?

Thanks,
Guenter

#9 lore raw

PATCH 1/1 Bluetooth: Simplify / fix return values from tk_request

From: Guenter Roeck <[email protected]>

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +4 -5
index d0b695ee4..30e8626dd 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
 	struct l2cap_chan *chan = conn->smp;
 	struct smp_chan *smp = chan->data;
 	u32 passkey = 0;
-	int ret = 0;
-	int err;
+	int ret;
 
 	/* Initialize key for JUST WORKS */
 	memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
 	/* If Just Works, Continue with Zero TK and ask user-space for
 	 * confirmation */
 	if (smp->method == JUST_WORKS) {
-		err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+		ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
 						hcon->type,
 						hcon->dst_type,
 						passkey, 1);
-		if (err)
-			return SMP_UNSPECIFIED;
+		if (ret)
+			return ret;
 		set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
 		return 0;
 	}
Signature · 1 line
2.24.1
Reviewed-by on v1 1/1
#12 lore raw
In reply to Guenter Roeck
Quoted 54 lines · Guenter Roeck

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>
---
 net/bluetooth/smp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
net/bluetooth/smp.c +4 -6
index d0b695ee49f6..30e8626dd553 100644
@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        struct l2cap_chan *chan = conn->smp;
        struct smp_chan *smp = chan->data;
        u32 passkey = 0;
-       int ret = 0;
-       int err;
+       int ret;
 
        /* Initialize key for JUST WORKS */
        memset(smp->tk, 0, sizeof(smp->tk));
@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        /* If Just Works, Continue with Zero TK and ask user-space for
         * confirmation */
        if (smp->method == JUST_WORKS) {
-               err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
+               ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
                                                hcon->type,
                                                hcon->dst_type,
                                                passkey, 1);
-               if (err)
-                       return SMP_UNSPECIFIED;
+               if (ret)
+                       return ret;
                set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
                return 0;
        }
--

2.17.1

maintainer
#10 lore raw
In reply to Sonny Sasaka

Hi Sonny,

Quoted 13 lines

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Quoted 7 lines
Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>

---
net/bluetooth/smp.c | 9 ++++-----

1 file changed, 4 insertions(+), 5 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#11 lore raw

Thanks, Marcel.

Thanks, Guenter for finding this out.

Quoted 30 lines · Marcel Holtmann

Hi Sonny,

Quoted 13 lines

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values. Stick with the existing variable. While at it, don't pre-initialize 'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors, not a bluetooth return code. The calling code converts the return value to SMP_UNSPECIFIED if needed.

Quoted 7 lines
Fixes 92516cd97fd4 ("Bluetooth: Always request for user confirmation for Just Works")
Cc Sonny Sasaka <[email protected]>

---
net/bluetooth/smp.c | 9 ++++-----

1 file changed, 4 insertions(+), 5 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel