[PATCH 1/1] Simplify, statement is always true.

Aaron Plattner aplattner at nvidia.com
Fri Sep 23 17:23:53 UTC 2016


On 09/21/2016 05:08 PM, Maya Rashish wrote:
> pVideo->bus is uint8_t, always less than 256.
> 
> Signed-off-by: Maya Rashish <coypu at sdf.org>
> ---
>  hw/xfree86/common/xf86pciBus.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
> index 8158c2b..bed4434 100644
> --- a/hw/xfree86/common/xf86pciBus.c
> +++ b/hw/xfree86/common/xf86pciBus.c
> @@ -1457,11 +1457,7 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
>  
>      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);
> +    snprintf(busnum, sizeof(busnum), "%d", pVideo->bus);
>  
>      XNFasprintf(&tmp, "PCI:%s:%d:%d",
>                  busnum, pVideo->dev, pVideo->func);
> 

Presumably this was to handle the old-style encoding of PCI domain into
the bus field -- we don't want to just drop the bus entirely, right? So
this should probably be

  if (pVideo->domain > 0)
      snprintf(busnum, sizeof(busnum), "%d@%d", pVideo->bus,
pVideo->domain);
  else
      snprintf(busnum, sizeof(busnum), "%d", pVideo->bus);

-- Aaron


More information about the xorg-devel mailing list