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

Andrew Donnellan ajd at linux.ibm.com
Tue Nov 10 23:01:01 AEDT 2020


On 10/11/20 10:19 pm, xiakaixu1987 at gmail.com wrote:
> From: Kaixu Xia <kaixuxia at tencent.com>
> 
> 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 <tencent_os_robot at tencent.com>
> Signed-off-by: Kaixu Xia <kaixuxia at tencent.com>

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 <ajd at linux.ibm.com>

> ---
>   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 at linux.ibm.com             IBM Australia Limited


More information about the Linuxppc-dev mailing list