As mentioned in the commit message, the comment helps in making it
explicit and evident that the missing break is not a human miss, but
intentional.
Hence, the comment should be considered as being added for the human code
readers / developers.

So even if some static analysis tool flags such an issue, it can be fairly
easy now to ignore that on manual inspection. If desired this can also be
stated in the comment itself like -

+                  //
+                  // No break here as this is an intentional fall through.
+                  // Ignore any static tool issue if pointed.
+                  //

Yes, there can be other solutions (which may or may not be worth the
effort), but for now I went with the least code change approach.

On Tue, Nov 7, 2023 at 11:29 PM Kinney, Michael D <
[email protected]> wrote:

> This comment style only works with Coverity.
>
> Other static analysis tools may flag the same issue again.
>
> It is better to update the logic so no static analysis tool will
> flag this issue.
>
> Mike
>
> > -----Original Message-----
> > From: [email protected] <[email protected]> On Behalf Of Laszlo
> > Ersek
> > Sent: Tuesday, November 7, 2023 8:23 AM
> > To: [email protected]; [email protected]
> > Cc: Ni, Ray <[email protected]>; Veeresh Sangolli
> > <[email protected]>
> > Subject: Re: [edk2-devel] [PATCH v2 2/5]
> > MdeModulePkg/Bus/Pci/PciBusDxe: Fix MISSING_BREAK Coverity issues
> >
> > On 11/7/23 07:19, Ranbir Singh wrote:
> > > From: Ranbir Singh <[email protected]>
> > >
> > > The function UpdatePciInfo has switch-case code in which there are
> > fall
> > > through from case 32: to case 64:. While this is seeemingly
> > intentional,
> > > it is not evident to any general code reader why there is no break;
> > in
> > > between. Adding
> > >
> > >     // No break; here as this is an intentional fallthrough.
> > >
> > > as comment in between makes it explicit. Incidentally, the comment
> > > satisfies Coverity as well.
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4239
> > >
> > > Cc: Ray Ni <[email protected]>
> > > Co-authored-by: Veeresh Sangolli <[email protected]>
> > > Signed-off-by: Ranbir Singh <[email protected]>
> > > Signed-off-by: Ranbir Singh <[email protected]>
> > > ---
> > >  MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > >
> > > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
> > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
> > > index 6594b8eae83f..eda97285ee18 100644
> > > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
> > > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
> > > @@ -1428,6 +1428,9 @@ UpdatePciInfo (
> > >                switch (Ptr->AddrSpaceGranularity) {
> > >                  case 32:
> > >                    PciIoDevice->PciBar[BarIndex].BarType =
> > PciBarTypeMem32;
> > > +                  //
> > > +                  // No break; here as this is an intentional fall
> > through.
> > > +                  //
> > >                  case 64:
> > >                    PciIoDevice->PciBar[BarIndex].BarTypeFixed =
> > TRUE;
> > >                    break;
> > > @@ -1440,6 +1443,9 @@ UpdatePciInfo (
> > >                switch (Ptr->AddrSpaceGranularity) {
> > >                  case 32:
> > >                    PciIoDevice->PciBar[BarIndex].BarType =
> > PciBarTypePMem32;
> > > +                  //
> > > +                  // No break; here as this is an intentional fall
> > through.
> > > +                  //
> > >                  case 64:
> > >                    PciIoDevice->PciBar[BarIndex].BarTypeFixed =
> > TRUE;
> > >                    break;
> >
> > Agree, but the semicolon's placement is awkward. I propose
> >
> >   No break here, as this is an intentional fall through.
> >
> > Reviewed-by: Laszlo Ersek <[email protected]>
> >
> >
> >
> > 
> >
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110890): https://edk2.groups.io/g/devel/message/110890
Mute This Topic: https://groups.io/mt/102438299/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to