public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Bluetooth: Move error check into the right if-clause
@ 2019-11-21  7:51 Marcel Holtmann
  2019-11-21 14:41 ` Johan Hedberg
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2019-11-21  7:51 UTC (permalink / raw)
  To: linux-bluetooth

The if-clause for hdev->setup should also include the error handling
since that is where the error really comes from. The code currently
works correctly since ret=0 is assigned early on, but it is a lot
harder to read and understand.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/hci_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0cc9ce917222..c957f0611f74 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1446,11 +1446,11 @@ static int hci_dev_do_open(struct hci_dev *hdev)
 	    test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
 		hci_sock_dev_event(hdev, HCI_DEV_SETUP);
 
-		if (hdev->setup)
+		if (hdev->setup) {
 			ret = hdev->setup(hdev);
-
-		if (ret)
-			goto setup_failed;
+			if (ret)
+				goto setup_failed;
+		}
 
 		if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) {
 			if (!bacmp(&hdev->public_addr, BDADDR_ANY))
-- 
2.23.0


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

* Re: [PATCH 1/2] Bluetooth: Move error check into the right if-clause
  2019-11-21  7:51 [PATCH 1/2] Bluetooth: Move error check into the right if-clause Marcel Holtmann
@ 2019-11-21 14:41 ` Johan Hedberg
  2019-11-21 23:36   ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2019-11-21 14:41 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Thu, Nov 21, 2019, Marcel Holtmann wrote:
> The if-clause for hdev->setup should also include the error handling
> since that is where the error really comes from. The code currently
> works correctly since ret=0 is assigned early on, but it is a lot
> harder to read and understand.
> 
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
>  net/bluetooth/hci_core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Both patches in this set have been applied to bluetooth-next. Thanks.

Johan

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

* Re: [PATCH 1/2] Bluetooth: Move error check into the right if-clause
  2019-11-21 14:41 ` Johan Hedberg
@ 2019-11-21 23:36   ` Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2019-11-21 23:36 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth

Hi Johan,

>> The if-clause for hdev->setup should also include the error handling
>> since that is where the error really comes from. The code currently
>> works correctly since ret=0 is assigned early on, but it is a lot
>> harder to read and understand.
>> 
>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
>> ---
>> net/bluetooth/hci_core.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Both patches in this set have been applied to bluetooth-next. Thanks.

so my cleanup patch was actually a mistake. In itself it was the right fix, but with the follow up patch, we actually want it that way to allow the invalid_bdaddr variable assignment to be done after hdev->setup.

I posted a v2 now that fixes that. We need to do a push --force to fix this up. A follow up patch would cause a hard to track history.

Regards

Marcel


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

end of thread, other threads:[~2019-11-21 23:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-21  7:51 [PATCH 1/2] Bluetooth: Move error check into the right if-clause Marcel Holtmann
2019-11-21 14:41 ` Johan Hedberg
2019-11-21 23:36   ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox