Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp738013lqc; Fri, 8 Mar 2024 10:09:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFFXbEqiAaJTPuKiAtlOEYBE0vI0Uh4UbT1Ph3gaek8Squ+8SmV4IXR3TQzucewoO4Ov0Q0KTxZJuxKT7BXz0+Byi14k9d2bfxX0rTrw== X-Google-Smtp-Source: AGHT+IET0cVZUvA52HYAsxVCP0KgwRzSBnPFfYvLI7VWp+dH/hZ2A0+3aua5V4rOQJUwVpeqSqYr X-Received: by 2002:a17:903:24c:b0:1dc:b531:833 with SMTP id j12-20020a170903024c00b001dcb5310833mr13786254plh.63.1709921345318; Fri, 08 Mar 2024 10:09:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709921345; cv=pass; d=google.com; s=arc-20160816; b=g3EQ7hbKSsQDPT71i7jC/Ai5/wab7Pch7g9i02PWur155RG0/GWi84f7KD9rJ/YWr4 YfvKOwZRbMflizMD1ZXhJSLrH+ffBmBbT/amR6sOdxOxVPRXpZ4LKUl0x9KSFUN88l6q 4HMAUmL9ysJ4Rc6nbmbR786RdE2IFxUFtmME949Bxpk/G7UO4Nf1FqbljAUVJCDQIROD QKr35tJsGPuohGvstHyvF2DeWi6eJ35xHZNcU5LY8dbGnzvbOM1tq17mkzxtnEstUoeV TyoErKN78uJ1a8mjR8pVp/dfLBFbk5wyH5UvZAoRZ5X0oaEe5lGgEa9CSiyVdrvQAjlL OO5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=sWXv5omFXAweWmoUVyVtz2fHCpDZD1l9Wn8KgiA2L2U=; fh=a3sutOB9PZqSxHtA3pld6jWl6JGY6MOto4tfBiytwsY=; b=hdFkRUbuz4ul637/p8V/Dpi+LX2TKhteY24p5UF7IH7X0ax02lesJnBCOtLtexmxGg /gU3hcw1OyrnaA5oxF6hgVbQecL7iiFlSzwM7Bi4lCOBgfwm/Jvc7EAIVdUKqM09+b9w eYMpdqEop6SbaHvO0pwUKirWPGZjnJve2mIom/4uja0EGD/PvPze1k+OTXjBxeoiCX3I z12yhz7VzHQmx/Sro+PWffHQTBFWpC54AXlpKrb8z/VeQIapHhzcti6rPSHLbKuOzILC zEKXH9jQBTawhTcypDZVOCmg5+XF1VxHPLK+nBUdqD5tzhMlplAmoV/i797Mk/VMIM6y FiaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=perches.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2388-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lv3-20020a1709032a8300b001dcce28a483si16781160plb.260.2024.03.08.10.09.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:09:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=perches.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2388-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CF89D2827EA for ; Fri, 8 Mar 2024 18:09:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB77454792; Fri, 8 Mar 2024 18:08:58 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D93A340861; Fri, 8 Mar 2024 18:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709921338; cv=none; b=N05if2MI0JQ80KPt2VxAwa0pQqeHZr9bCZZUKW+7OiNnRXQnvjWgErTZMIq2Z7XvxDgn9cBNXWBfz/44Cw9+V5UEA8IIRdNWtVSFrtPnZScEZwZbPUKlMbdgBc0vvO0yJ8dnAog8Szb3enSUkK2FY5jJe67DB51xzyX8FWcHsYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709921338; c=relaxed/simple; bh=H81oFEfhqXhD4JoDGucsCDDFcb8LFbVo8RNDJECQhY4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=G+Nl8u1GldQDudP40SHzozeA0KSAsrxe6hJ/hLugvW3cgcoJGmqymQAHLDjJ8AyFsaHZ7kmvz9EgX8TLVc2Q29TF7DW4/Pq2X8ePL0Ln3Kx2PiMXWy5vf/Vflo2sNmr43PPdQG2oc17BHc5eGOURzhzkdWmZfKZSTdjUW88RsKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 957AA1208E5; Fri, 8 Mar 2024 18:08:49 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA id 4B4DD2002A; Fri, 8 Mar 2024 18:08:47 +0000 (UTC) Message-ID: <67b5221c6ff05cf78070fbbe7f7f06f974b52e3d.camel@perches.com> Subject: Re: [PATCH] Bluetooth: bfusb: Updated code to follow style guide From: Joe Perches To: Ayaan Mirza Baig , marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 08 Mar 2024 10:08:46 -0800 In-Reply-To: <20240308162037.100226-1-ayaanmirza.788@gmail.com> References: <20240308162037.100226-1-ayaanmirza.788@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Stat-Signature: npj597os666dgwgduzftnmxcjxes3fez X-Rspamd-Server: rspamout07 X-Rspamd-Queue-Id: 4B4DD2002A X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+yGzGzyoaIRu86TK2LukGXJfxCW7uAtmM= X-HE-Tag: 1709921327-612833 X-HE-Meta: U2FsdGVkX18x0L6aBeTS/bQkIaD0h4VPputVXGjRSk/2rfub5MAAMzGqUk6TgpLALxd77ROoP2pRY/F9JohJNFSWu4AvXQ/BEWOyFWyRBjpf0qITkqR2iZwtZ+aYb95hDFhB7Tz9+aULUUYp/YjNijJPHTbJGNysVNEcV3njSZKHnCLExhr+I74ajrhWpkPF4pKn7GxR3wWrX80/23FLUr2tQ/aTty3IipcUVFNoEbBJHSz5HrEQKUGr9ZVBTakPBnkhktEqJOjXM9olgy328F1EKzfByRUjSHK6hCWHy3KEWcD9cwDmbgHysE4LhfW7 On Fri, 2024-03-08 at 21:50 +0530, Ayaan Mirza Baig wrote: > Added indendations, removed trailing spaces, added empty lines after decl= aration. 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 =20 switch (pkt_type) { case HCI_EVENT_PKT: - if (len >=3D HCI_EVENT_HDR_SIZE) { - struct hci_event_hdr *hdr =3D (struct hci_event_hdr *) buf; - pkt_len =3D 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 =3D HCI_EVENT_HDR_SIZE + ((struct hci_event_hdr *)buf)->plen; break; =20 case HCI_ACLDATA_PKT: - if (len >=3D HCI_ACL_HDR_SIZE) { - struct hci_acl_hdr *hdr =3D (struct hci_acl_hdr *) buf; - pkt_len =3D 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 =3D HCI_ACL_HDR_SIZE + __le16_to_cpu(((struct hci_acl_hdr *)buf= )->dlen); break; =20 case HCI_SCODATA_PKT: - if (len >=3D HCI_SCO_HDR_SIZE) { - struct hci_sco_hdr *hdr =3D (struct hci_sco_hdr *) buf; - pkt_len =3D 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 =3D HCI_SCO_HDR_SIZE + ((struct hci_sco_hdr *)buf)->dlen; break; } =20 @@ -365,9 +359,8 @@ static void bfusb_rx_complete(struct urb *urb) buf +=3D 3; } =20 - if (count < len) { + if (count < len) bt_dev_err(data->hdev, "block extends over URB buffer ranges"); - } =20 if ((hdr & 0xe1) =3D=3D 0xc1) bfusb_recv_block(data, hdr, buf, len);