[dpdk-dev] [PATCH v2 04/15] eal: Fix needless incrementation of pci_map_addr

Iremonger, Bernard bernard.iremonger at intel.com
Fri Mar 13 15:49:03 CET 2015



> -----Original Message-----
> From: Tetsuya Mukawa [mailto:mukawa at igel.co.jp]
> Sent: Thursday, March 12, 2015 10:18 AM
> To: dev at dpdk.org
> Cc: Iremonger, Bernard; Richardson, Bruce; Tetsuya Mukawa
> Subject: [PATCH v2 04/15] eal: Fix needless incrementation of pci_map_addr
> 
> When pci_map_resource() is failed, mapaddr will be MAP_FAILED.
> In this case, pci_map_addr should not be incremented.
> The patch fixes it. Also, fix below.
>  - To shrink code, move close().
>  - Remove fail variable.
> 
> Signed-off-by: Tetsuya Mukawa <mukawa at igel.co.jp>
> ---
>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> index 901f277..2741c62 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> @@ -337,7 +337,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)
>  	maps = uio_res->maps;
>  	for (i = 0, map_idx = 0; i != PCI_MAX_RESOURCE; i++) {
>  		int fd;
> -		int fail = 0;
> 
>  		/* skip empty BAR */
>  		phaddr = dev->mem_resource[i].phys_addr; @@ -371,18 +370,13 @@
> pci_uio_map_resource(struct rte_pci_device *dev)
> 
>  		mapaddr = pci_map_resource(pci_map_addr, fd, 0,
>  				(size_t)dev->mem_resource[i].len, 0);
> +		close(fd);
>  		if (mapaddr == MAP_FAILED)
> -			fail = 1;
> +			goto fail1;
> 
>  		pci_map_addr = RTE_PTR_ADD(mapaddr,
>  				(size_t)dev->mem_resource[i].len);
> 
> -		if (fail) {
> -			close(fd);
> -			goto fail1;
> -		}
> -		close(fd);
> -
>  		maps[map_idx].phaddr = dev->mem_resource[i].phys_addr;
>  		maps[map_idx].size = dev->mem_resource[i].len;
>  		maps[map_idx].addr = mapaddr;
> --
> 1.9.1
Hi Tetsuya,

This patch could be squashed into patch 3.

Regards,

Bernard.




More information about the dev mailing list