[PATCH v2 xserver 1/3] xfree86: Silence always true condition warning.

walter harms wharms at bfs.de
Mon Mar 27 15:41:39 UTC 2017


looks nice

Reviewed-by: wharms at bfs.de

Am 27.03.2017 17:36, schrieb Michal Srb:
> xf86pciBus.c:1464:21: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Wtautological-constant-out-of-range-compare]
>     if (pVideo->bus < 256)
> 
> The code used to be in xf86FormatPciBusNumber and compared parameter which was int, but since b967bf2a it was inlined now it works with uint8_t.
> 
> v2: Merge the snprintf into the following XNFasprintf.
> ---
>  hw/xfree86/common/xf86pciBus.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
> index 9adfee5..d589ece 100644
> --- a/hw/xfree86/common/xf86pciBus.c
> +++ b/hw/xfree86/common/xf86pciBus.c
> @@ -1456,19 +1456,12 @@ void
>  xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
>                         GDevRec * GDev, int *chipset)
>  {
> -    char busnum[8];
>      char *tmp;
>  
>      pVideo = (struct pci_device *) busData;
>  
> -    if (pVideo->bus < 256)
> -        snprintf(busnum, sizeof(busnum), "%d", pVideo->bus);
> -    else
> -        snprintf(busnum, sizeof(busnum), "%d@%d",
> -                 pVideo->bus & 0x00ff, pVideo->bus >> 8);
> -
> -    XNFasprintf(&tmp, "PCI:%s:%d:%d",
> -                busnum, pVideo->dev, pVideo->func);
> +    XNFasprintf(&tmp, "PCI:%d:%d:%d",
> +                pVideo->bus, pVideo->dev, pVideo->func);
>      GDev->busID = tmp;
>  
>      GDev->chipID = pVideo->device_id;


More information about the xorg-devel mailing list