Linux-PCI Archive on lore.kernel.org
 help / color / Atom feed
* 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, back to index

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

Linux-PCI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pci/0 linux-pci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pci linux-pci/ https://lore.kernel.org/linux-pci \
		linux-pci@vger.kernel.org
	public-inbox-index linux-pci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git