Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp791297lqh; Sun, 5 May 2024 02:06:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBXofdu5T3JPqP4W4xudxP6eQ8LyI+cGywdb6RtJsxzEq51nofdGEdCh/LO3W7MaNKUFwsDYEmQ+PrLS8QeVg//VcLV3piI/JYSF9Wbg== X-Google-Smtp-Source: AGHT+IFyiwI9efzsjolkA801KUNo2ZP/s9KhDyNXuKiMTQIG59zl2mur1Xxsbc7Bl06Sd63CAeQA X-Received: by 2002:a05:6214:5157:b0:6a0:e768:aa7d with SMTP id kh23-20020a056214515700b006a0e768aa7dmr16914870qvb.23.1714900006305; Sun, 05 May 2024 02:06:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714900006; cv=pass; d=google.com; s=arc-20160816; b=K5LDcgjkc7mdVXO9V2U11UOAjE6mr7fsT0nuV63ZouN6h36kx3DBxPt8tNSxRKwPaU +NpkuhQoHZv96xITtT3byVa1Wuy+Xhv2rKS1xCbVTRcytEAzymZzyjeGi0Ln4L9rE1ax zBpBKCP4ob8lZtCo1nXH2oH+O8oWTa1nX5wnqQJvIWw5zkXUd0Clwi8E6T9axV2EBz0X ZbsBr6V3auLIsK37aPTQIp7jUYrjBIhzANJ0qWFcTHqDm/KgQshZA7i/r3wA44dTnfwA Q6WefKbUi/bbNa13RdN7Yp+G4TCU+yjE8pbZ5uk0ryHGPpe6Pw6MdVlStsBQpJ6Y3wUu zbsw== 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:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=RiBDRjpnVwWZ/L4d65VWLNETY36x2v5A1qooU4xt2mw=; fh=ZZX2o4/w0nbKGgHU4+D9rKIYOXmeb9aLqZhU4eleZTg=; b=NOinnz6LJoK/5QFkFe5RFPKMwF+9FLv/LoWGztSgjcG0NT2eiBhp7lDrj4pIUDLNt/ 9U1IaHarEOWkVPdCxgWJ/4Kgg7o6Ww5/xM3GOnujtZm3Uu+t6+4UYGwXmUEZ+fl86bvT 7IYK8KaEbS+0uERqOCFKQVup4TaXj9TesCRJjnIsH5QPcplWERedt8517j0mAcoX2uwG KN2tnPOVKYL5VCNVi4nCjjOO8+gQ3ZtNl82DJvtMR4g27cpgsjosOyu7WfHg0THbFOmI FH30yTP1hM7nXj5XPtKWifCsiVQoRHoR66bko4lYd3Dy7h+/yJtdTyHKpwf9mGZy7y6D bUAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=acy4RS18; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-168931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t8-20020a0562140c6800b0069b4d64ab0asi6834468qvj.339.2024.05.05.02.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 02:06:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=acy4RS18; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-168931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 09A811C20B9A for ; Sun, 5 May 2024 09:06:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB867B657; Sun, 5 May 2024 09:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="acy4RS18" Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) (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 29D34566A; Sun, 5 May 2024 09:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714899993; cv=none; b=iOTlz5K6Wo3yVZM+rVIiP3FqsjpNjKJrantzP8HYGkAvnSk18W/D7Q9/JfYKkAcI4vvSKLpVfiMPHILvUU2rA7+8G3ZCJfCEwyCg7eT74q3mnPkwA5y1s/8lTc4/oOEhlaUTiCzrddR89QT2VQOFNzSPQmAU60q+Rnn83EHnpQk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714899993; c=relaxed/simple; bh=Oh1k6vjiKtFaFfOeSm2f1cOY0uN6C0bEQ3sYUKgAErU=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=hkc/6Tdob1MpIRfz+0jLPFSbn8aASH08hX3LwOEynAvcqbpF1lW2127jUoKFz5ep6ItYZkVnvL1oo0hOxHFlAIylbC/6FVdetGXDFB7eZxGIWRB/viS6EKTQw4Cu35LclkqWra/RnjRz6FMCm5CyhcanwWMSBIHF8Hs4kFFLvqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=acy4RS18; arc=none smtp.client-ip=192.134.164.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=RiBDRjpnVwWZ/L4d65VWLNETY36x2v5A1qooU4xt2mw=; b=acy4RS18ot7FCBRUmPvjBMnII/FVeyHyf2QUT5r9M18nHfXMHVEwHh/m UsabrJkQOMLXkXk4h4yl2o6qkghHZj3uwiQf26WvNp5a2zGr7H0lDAd9e xabMgx28gWNcAR36c510ISxXurYbTaVdQTe2Et0ntP1tCzbzBD6oA2lVH M=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.07,255,1708383600"; d="scan'208";a="86396322" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2024 11:06:21 +0200 Date: Sun, 5 May 2024 11:06:20 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Markus Elfring cc: linux-bluetooth@vger.kernel.org, kernel-janitors@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , LKML Subject: Re: [PATCH] Bluetooth: qca: Use common error handling code in two functions In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Sun, 5 May 2024, Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 5 May 2024 10:30:28 +0200 > > Add a jump target so that the setting of an error code can be better reused > at the end of these function implementations. > > This issue was transformed by using the Coccinelle software. This reduces readability, and backwards jumps are rarely desirable. julia > > Signed-off-by: Markus Elfring > --- > drivers/bluetooth/btqca.c | 35 +++++++++++++++++------------------ > 1 file changed, 17 insertions(+), 18 deletions(-) > > diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c > index cc61014ffbc9..1833aaa6d87b 100644 > --- a/drivers/bluetooth/btqca.c > +++ b/drivers/bluetooth/btqca.c > @@ -108,10 +108,8 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) > return err; > } > > - if (skb->len < sizeof(*edl)) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < sizeof(*edl)) > + goto e_ilseq; > > edl = (struct edl_event_hdr *)(skb->data); > > @@ -123,17 +121,13 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) > goto out; > } > > - if (skb->len < sizeof(*edl) + 1) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < sizeof(*edl) + 1) > + goto e_ilseq; > > build_lbl_len = edl->data[0]; > > - if (skb->len < sizeof(*edl) + 1 + build_lbl_len) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < sizeof(*edl) + 1 + build_lbl_len) > + goto e_ilseq; > > build_label = kstrndup(&edl->data[1], build_lbl_len, GFP_KERNEL); > if (!build_label) > @@ -145,6 +139,10 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) > out: > kfree_skb(skb); > return err; > + > +e_ilseq: > + err = -EILSEQ; > + goto out; > } > > static int qca_send_patch_config_cmd(struct hci_dev *hdev) > @@ -224,8 +222,7 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) > edl = skb_pull_data(skb, sizeof(*edl)); > if (!edl) { > bt_dev_err(hdev, "QCA read board ID with no header"); > - err = -EILSEQ; > - goto out; > + goto e_ilseq; > } > > if (edl->cresp != EDL_CMD_REQ_RES_EVT || > @@ -235,10 +232,8 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) > goto out; > } > > - if (skb->len < 3) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < 3) > + goto e_ilseq; > > *bid = (edl->data[1] << 8) + edl->data[2]; > bt_dev_dbg(hdev, "%s: bid = %x", __func__, *bid); > @@ -246,6 +241,10 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) > out: > kfree_skb(skb); > return err; > + > +e_ilseq: > + err = -EILSEQ; > + goto out; > } > > int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) > -- > 2.44.0 > > >