[PATCH] powerpc/powernv/sriov: fix unsigned int win compared to less than zero

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE2114d LANDED

Landed in mainline as 027717a45ca2 on 2020-11-19.

4 messages, 4 authors, 2020-11-25 · open the first message on its own page

[PATCH] powerpc/powernv/sriov: fix unsigned int win compared to less than zero

From: <hidden>
Date: 2020-11-10 11:19:38

From: Kaixu Xia <redacted>

Fix coccicheck warning:

./arch/powerpc/platforms/powernv/pci-sriov.c:443:7-10: WARNING: Unsigned expression compared with zero: win < 0
./arch/powerpc/platforms/powernv/pci-sriov.c:462:7-10: WARNING: Unsigned expression compared with zero: win < 0

Reported-by: Tosk Robot <redacted>
Signed-off-by: Kaixu Xia <redacted>
---
 arch/powerpc/platforms/powernv/pci-sriov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/pci-sriov.c b/arch/powerpc/platforms/powernv/pci-sriov.c
index c4434f20f42f..92fc861c528f 100644
--- a/arch/powerpc/platforms/powernv/pci-sriov.c
+++ b/arch/powerpc/platforms/powernv/pci-sriov.c
@@ -422,7 +422,7 @@ static int pnv_pci_vf_assign_m64(struct pci_dev *pdev, u16 num_vfs)
 {
 	struct pnv_iov_data   *iov;
 	struct pnv_phb        *phb;
-	unsigned int           win;
+	int		       win;
 	struct resource       *res;
 	int                    i, j;
 	int64_t                rc;
-- 
2.20.0

Re: [PATCH] powerpc/powernv/sriov: fix unsigned int win compared to less than zero

From: Andrew Donnellan <hidden>
Date: 2020-11-10 12:02:13

On 10/11/20 10:19 pm, xiakaixu1987@gmail.com wrote:
From: Kaixu Xia <redacted>

Fix coccicheck warning:

./arch/powerpc/platforms/powernv/pci-sriov.c:443:7-10: WARNING: Unsigned expression compared with zero: win < 0
./arch/powerpc/platforms/powernv/pci-sriov.c:462:7-10: WARNING: Unsigned expression compared with zero: win < 0

Reported-by: Tosk Robot <redacted>
Signed-off-by: Kaixu Xia <redacted>
This seems like the right fix, the value assigned to win can indeed be 
-1 so it should be signed. Thanks for sending the patch.

Reviewed-by: Andrew Donnellan <redacted>
quoted hunk
---
  arch/powerpc/platforms/powernv/pci-sriov.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/pci-sriov.c b/arch/powerpc/platforms/powernv/pci-sriov.c
index c4434f20f42f..92fc861c528f 100644
--- a/arch/powerpc/platforms/powernv/pci-sriov.c
+++ b/arch/powerpc/platforms/powernv/pci-sriov.c
@@ -422,7 +422,7 @@ static int pnv_pci_vf_assign_m64(struct pci_dev *pdev, u16 num_vfs)
  {
  	struct pnv_iov_data   *iov;
  	struct pnv_phb        *phb;
-	unsigned int           win;
+	int		       win;
  	struct resource       *res;
  	int                    i, j;
  	int64_t                rc;
-- 
Andrew Donnellan              OzLabs, ADL Canberra
ajd@linux.ibm.com             IBM Australia Limited

Re: [PATCH] powerpc/powernv/sriov: fix unsigned int win compared to less than zero

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2020-11-17 03:07:57

Andrew Donnellan [off-list ref] writes:
On 10/11/20 10:19 pm, xiakaixu1987@gmail.com wrote:
quoted
From: Kaixu Xia <redacted>

Fix coccicheck warning:

./arch/powerpc/platforms/powernv/pci-sriov.c:443:7-10: WARNING: Unsigned expression compared with zero: win < 0
./arch/powerpc/platforms/powernv/pci-sriov.c:462:7-10: WARNING: Unsigned expression compared with zero: win < 0

Reported-by: Tosk Robot <redacted>
Signed-off-by: Kaixu Xia <redacted>
This seems like the right fix, the value assigned to win can indeed be 
-1 so it should be signed. Thanks for sending the patch.

Reviewed-by: Andrew Donnellan <redacted>
I'll add:

  Fixes: 39efc03e3ee8 ("powerpc/powernv/sriov: Move M64 BAR allocation into a helper")

Which I think is the culprit as it changed:

  if (win >= phb->ioda.m64_bar_idx + 1)

to:

  if (win < 0)


cheers

Re: [PATCH] powerpc/powernv/sriov: fix unsigned int win compared to less than zero

From: Michael Ellerman <hidden>
Date: 2020-11-25 11:58:22

On Tue, 10 Nov 2020 19:19:30 +0800, xiakaixu1987@gmail.com wrote:
Fix coccicheck warning:

./arch/powerpc/platforms/powernv/pci-sriov.c:443:7-10: WARNING: Unsigned expression compared with zero: win < 0
./arch/powerpc/platforms/powernv/pci-sriov.c:462:7-10: WARNING: Unsigned expression compared with zero: win < 0
Applied to powerpc/next.

[1/1] powerpc/powernv/sriov: fix unsigned int win compared to less than zero
      https://git.kernel.org/powerpc/c/027717a45ca251a7ba67a63db359994836962cd2

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help