Skip to contentSkip to conversation

pcie-mediatek.c coverity issue #1437218

DISCUSSION Bjorn Helgaas 2 participants 2 messages Oct 27, 2020 – Nov 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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);

maintainer
#1 lore raw

Hi Ryder,

Quoted 13 lines · Bjorn Helgaas

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.

Quoted 5 lines
     	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

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek