* pcie-mediatek.c coverity issue #1437218
@ 2020-10-27 16:19 Bjorn Helgaas
2020-11-27 9:11 ` Matthias Brugger
0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Helgaas @ 2020-10-27 16:19 UTC (permalink / raw)
To: Ryder Lee; +Cc: linux-pci, linux-mediatek
Hi Ryder,
Please take a look at this issue reported by Coverity:
760 static int mtk_pcie_startup_port(struct mtk_pcie_port *port)
761 {
762 struct mtk_pcie *pcie = port->pcie;
CID 1437218 (#1 of 1): Wrong operator used
(CONSTANT_EXPRESSION_RESULT) operator_confusion: (port->slot << 3) & 7
is always 0 regardless of the values of its operands. This occurs as
an initializer.
Did you intend to use right-shift (>>) in port->slot << 3?
763 u32 func = PCI_FUNC(port->slot << 3);
764 u32 slot = PCI_SLOT(port->slot << 3);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: pcie-mediatek.c coverity issue #1437218
2020-10-27 16:19 pcie-mediatek.c coverity issue #1437218 Bjorn Helgaas
@ 2020-11-27 9:11 ` Matthias Brugger
0 siblings, 0 replies; 2+ messages in thread
From: Matthias Brugger @ 2020-11-27 9:11 UTC (permalink / raw)
To: Bjorn Helgaas, Ryder Lee; +Cc: linux-pci, linux-mediatek, Frank Wunderlich
Hi Ryder,
On 27/10/2020 17:19, Bjorn Helgaas wrote:
> Hi Ryder,
>
> Please take a look at this issue reported by Coverity:
>
> 760 static int mtk_pcie_startup_port(struct mtk_pcie_port *port)
> 761 {
> 762 struct mtk_pcie *pcie = port->pcie;
>
> CID 1437218 (#1 of 1): Wrong operator used
> (CONSTANT_EXPRESSION_RESULT) operator_confusion: (port->slot << 3) & 7
> is always 0 regardless of the values of its operands. This occurs as
> an initializer.
>
> Did you intend to use right-shift (>>) in port->slot << 3?
>
> 763 u32 func = PCI_FUNC(port->slot << 3);
> 764 u32 slot = PCI_SLOT(port->slot << 3);
>
AFAIK pcie is working. Could you have a look on this code snippet? It seems as
if there is something fishy.
Thanks,
Matthias
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-27 9:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 16:19 pcie-mediatek.c coverity issue #1437218 Bjorn Helgaas
2020-11-27 9:11 ` Matthias Brugger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).