Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2942104ybc; Thu, 21 Nov 2019 00:28:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwntX/BBJFG5g/Mse+0ceDlpstA5MXxj5PKHw0/lVgb0YEavwoZ91UWb19jSEart9CR/jvM X-Received: by 2002:a17:906:fcdb:: with SMTP id qx27mr12047447ejb.255.1574324896249; Thu, 21 Nov 2019 00:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574324896; cv=none; d=google.com; s=arc-20160816; b=t6ycA0n73FffZIKEWaB0nk3UVyP10ckO3H2saUAintHn0lHmFVed84mjbj0hmjfQDh h5DbB/8Kb7H7nSaYaby61HG8m54515aXNWBbu8x47b1J5nCQqmEqzuiNXz9H4rMzhVZy mkWPuG7rZrDxIAsYrAtjqrRbpHFN4k5fDn5Bxz0oeDa4PjTdDVgcAma387Id18XFILe8 c4yHiE/zWY75fb9APFex6Zu8AFKPSSstrI54RQdndr4NXet/KEAM3Me0khm3KEusWLr9 jM1Ivx2pHN2ZQ9ctvfh4hoVXnraWfn0yds8i1QQagH1lG+XnxLmr6YFcc7am34xZo9Wn i2bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=EllW+YWsuNaUPV5XjS84bQyBK8LXe9yRUFZRkzrJ4CA=; b=MGTc3pbBizL1DHxqGHvjrkX20+FepKKRQ30C3GO4oEPvrXBzCXnEydbWx5Ef7OB2Rw jPSFqdX8pLy5y2NYFOw4JnLg6kwk2IEUiGiHI/twhQsVs7yl6KMaUCgY8+EXLDkhQ+lL V/8m3oE+BI7u7PLJUHzlvwuXQACC8wRwJINFufL66LD98B5Q24MhXszYpFKxC3orVMKE /RbUZD/FtfR26WZ+1Mm6xQ4K+6m5dScjbVEX45dhxBnbQElwzAP+5qA0CKLoQMO9JM0p yFpDyd5v8PKFG4zRslvZRg66dyI/8Jx6oC5xsZ2JYpGQXA7JkT8xivdXcTzkUoX3V4iU ItEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si1291308ejz.252.2019.11.21.00.27.49; Thu, 21 Nov 2019 00:28:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726170AbfKUI1l (ORCPT + 99 others); Thu, 21 Nov 2019 03:27:41 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:35756 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbfKUI1l (ORCPT ); Thu, 21 Nov 2019 03:27:41 -0500 Received: from localhost.localdomain (tmo-101-191.customers.d1-online.com [80.187.101.191]) by mail.holtmann.org (Postfix) with ESMTPSA id 3534DCED0E for ; Thu, 21 Nov 2019 09:36:47 +0100 (CET) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: Move error check into the right if-clause Date: Thu, 21 Nov 2019 08:51:29 +0100 Message-Id: <20191121075130.92705-1-marcel@holtmann.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 --- 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