mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Ayaan Mirza Baig <ayaanmirza.788@gmail.com>,
	marcel@holtmann.org,  luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: bfusb: Updated code to follow style guide
Date: Fri, 08 Mar 2024 10:08:46 -0800	[thread overview]
Message-ID: <67b5221c6ff05cf78070fbbe7f7f06f974b52e3d.camel@perches.com> (raw)
In-Reply-To: <20240308162037.100226-1-ayaanmirza.788@gmail.com>

On Fri, 2024-03-08 at 21:50 +0530, Ayaan Mirza Baig wrote:
> Added indendations, removed trailing spaces, added empty lines after declaration.

indendations/indentations.

Do please try to not just mollify checkpatch message bleats
but try to make the code more intelligible.

I think the tests are backwards would better be written
with fewer block indentations and direct returns without
creating used-once temporaries like:

---
 drivers/bluetooth/bfusb.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index cab93935cc7f1..68587424187e6 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -273,33 +273,27 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 
 		switch (pkt_type) {
 		case HCI_EVENT_PKT:
-			if (len >= HCI_EVENT_HDR_SIZE) {
-				struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf;
-				pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen;
-			} else {
+			if (len < HCI_EVENT_HDR_SIZE) {
 				bt_dev_err(data->hdev, "event block is too short");
 				return -EILSEQ;
 			}
+			pkt_len = HCI_EVENT_HDR_SIZE + ((struct hci_event_hdr *)buf)->plen;
 			break;
 
 		case HCI_ACLDATA_PKT:
-			if (len >= HCI_ACL_HDR_SIZE) {
-				struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) buf;
-				pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen);
-			} else {
+			if (len < HCI_ACL_HDR_SIZE) {
 				bt_dev_err(data->hdev, "data block is too short");
 				return -EILSEQ;
 			}
+			pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(((struct hci_acl_hdr *)buf)->dlen);
 			break;
 
 		case HCI_SCODATA_PKT:
-			if (len >= HCI_SCO_HDR_SIZE) {
-				struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) buf;
-				pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen;
-			} else {
+			if (len < HCI_SCO_HDR_SIZE) {
 				bt_dev_err(data->hdev, "audio block is too short");
 				return -EILSEQ;
 			}
+			pkt_len = HCI_SCO_HDR_SIZE + ((struct hci_sco_hdr *)buf)->dlen;
 			break;
 		}
 
@@ -365,9 +359,8 @@ static void bfusb_rx_complete(struct urb *urb)
 			buf   += 3;
 		}
 
-		if (count < len) {
+		if (count < len)
 			bt_dev_err(data->hdev, "block extends over URB buffer ranges");
-		}
 
 		if ((hdr & 0xe1) == 0xc1)
 			bfusb_recv_block(data, hdr, buf, len);


      reply	other threads:[~2024-03-08 18:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08 16:20 Ayaan Mirza Baig
2024-03-08 18:08 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67b5221c6ff05cf78070fbbe7f7f06f974b52e3d.camel@perches.com \
    --to=joe@perches.com \
    --cc=ayaanmirza.788@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®