From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B35787803D1 for ; Tue, 7 Nov 2023 16:13:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6UVzNnwOXzft2D/9tDHeK8ur/gwUB+6arBN94o7r+mE=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699373600; v=1; b=Ts79qHjHvyf5+VLt8nHUO9FvuaTN5+mbOhICuFEIHREApZnmDpra1HZUr0zMQo1YvGbC+Wfl BR2WUG525PFS9VjrbeiXRSxhvdceyHwkkvMZBhemNl7VYjT+LENSgXwjDd0KmNsckrkFruiYfSl ZGmeO+CiinmAU59E671NVhKM= X-Received: by 127.0.0.2 with SMTP id SiR0YY7687511xauITevgdzl; Tue, 07 Nov 2023 08:13:20 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.14886.1699373599593842908 for ; Tue, 07 Nov 2023 08:13:19 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-5sH5YWyFO6WT_oIh-NxYQQ-1; Tue, 07 Nov 2023 11:13:16 -0500 X-MC-Unique: 5sH5YWyFO6WT_oIh-NxYQQ-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3D102806044; Tue, 7 Nov 2023 16:13:14 +0000 (UTC) X-Received: from [10.39.193.64] (unknown [10.39.193.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB5A7492BE7; Tue, 7 Nov 2023 16:13:13 +0000 (UTC) Message-ID: <82cfaff1-1be3-6615-3ce3-0039ee4ec1bf@redhat.com> Date: Tue, 7 Nov 2023 17:13:12 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 2/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix MISSING_BREAK Coverity issues To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli References: <20231107055800.86752-1-rsingh@ventanamicro.com> <20231107055800.86752-3-rsingh@ventanamicro.com> From: "Laszlo Ersek" In-Reply-To: <20231107055800.86752-3-rsingh@ventanamicro.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: sPr2yIW6HlfLh6A8SQbbIPFkx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Ts79qHjH; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 11/7/23 06:58, Ranbir Singh wrote: > From: Ranbir Singh >=20 > The functions > XhcInitializeEndpointContext and XhcInitializeEndpointContext64 has > a switch-case code in which the case USB_ENDPOINT_CONTROL: falls > through to default: >=20 > While this may be intentional, it is not evident to any general code > reader why there is no break; in between. Adding >=20 > // No break; here as this is an intentional fallthrough. >=20 > as comment in between makes it explicit. Incidentally, the comment > satisfies Coverity as well. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4221 >=20 > Cc: Ray Ni > Co-authored-by: Veeresh Sangolli > Signed-off-by: Ranbir Singh > Signed-off-by: Ranbir Singh > --- > MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/= Pci/XhciDxe/XhciSched.c > index 05528a478baf..2afecd40cab0 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > @@ -2979,6 +2979,9 @@ XhcInitializeEndpointContext ( > // Do not support control transfer now. > // > DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unsupport Con= trol EP found, Transfer ring is not allocated.\n")); > + // > + // No break; here as this is an intentional fall through. > + // > default: > DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unknown EP fo= und, Transfer ring is not allocated.\n")); > EpDesc =3D (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->L= ength); > @@ -3182,6 +3185,9 @@ XhcInitializeEndpointContext64 ( > // Do not support control transfer now. > // > DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unsupport C= ontrol EP found, Transfer ring is not allocated.\n")); > + // > + // No break; here as this is an intentional fall through. > + // > default: > DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unknown EP = found, Transfer ring is not allocated.\n")); > EpDesc =3D (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->L= ength); Eww, the contradictory DEBUG messages look awkard (in the original code), "= unsupported" vs. "unknown"! How about this one instead: diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 05528a478baf..66e2e7044e06 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -3034,6 +3034,7 @@ XhcInitializeEndpointContext64 ( EFI_PHYSICAL_ADDRESS PhyAddr; UINT8 Interval; TRANSFER_RING *EndpointTransferRing; + UINT8 EpType; =20 MaxDci =3D 0; =20 @@ -3074,7 +3075,8 @@ XhcInitializeEndpointContext64 ( InputContext->EP[Dci-1].MaxBurstSize =3D 0x0; } =20 - switch (EpDesc->Attributes & USB_ENDPOINT_TYPE_MASK) { + EpType =3D EpDesc->Attributes & USB_ENDPOINT_TYPE_MASK; + switch (EpType) { case USB_ENDPOINT_BULK: if (Direction =3D=3D EfiUsbDataIn) { InputContext->EP[Dci-1].CErr =3D 3; @@ -3177,13 +3179,16 @@ XhcInitializeEndpointContext64 ( =20 break; =20 - case USB_ENDPOINT_CONTROL: - // - // Do not support control transfer now. - // - DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unsupport Con= trol EP found, Transfer ring is not allocated.\n")); default: - DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unknown EP fo= und, Transfer ring is not allocated.\n")); + DEBUG (( + DEBUG_INFO, + "%a: %a found, Transfer ring is not allocated.\n", + __func__, + (EpType =3D=3D USB_ENDPOINT_CONTROL ? + "Unsupported Control EP" : + "Unknown EP" + ) + )); EpDesc =3D (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Len= gth); continue; } -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110861): https://edk2.groups.io/g/devel/message/110861 Mute This Topic: https://groups.io/mt/102438128/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-