Skip to content

Commit

Permalink
Improved PCI address parsing in intitialization
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Sep 15, 2023
1 parent ea268a6 commit 018f661
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dp_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,10 @@ static int dp_port_fill_info(struct dp_port *port)
if (!busname || strncmp(busname, "pci", 4) != 0)
return DP_ERROR;

domain_num = 0; // can be omitted in the name
pciaddr = rte_dev_name(info.device);
if (sscanf(pciaddr, "%04x:%02x:%02x.%02x", &domain_num, &bus_num, &dev_num, &func_num) != 4)
if (sscanf(pciaddr, "%04x:%02x:%02x.%02x", &domain_num, &bus_num, &dev_num, &func_num) != 4
&& sscanf(pciaddr, "%02x:%02x.%02x", &bus_num, &dev_num, &func_num) != 3)
return DP_ERROR;

port->pci_addr.domain = domain_num;
Expand Down

0 comments on commit 018f661

Please sign in to comment.