diff options
| author | Stefan Eßer <se@FreeBSD.org> | 2016-02-19 14:01:35 +0000 |
|---|---|---|
| committer | Stefan Eßer <se@FreeBSD.org> | 2016-02-19 14:01:35 +0000 |
| commit | a28a4d77b6ae826aec5331854d735c0f360c7115 (patch) | |
| tree | 8895acf745257fbc49f37b35c6eceeedde010941 /usr.sbin/pciconf | |
| parent | 64a3a6304e31a60badf015637339f0d869f8b46e (diff) | |
Notes
Diffstat (limited to 'usr.sbin/pciconf')
| -rw-r--r-- | usr.sbin/pciconf/pciconf.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index e743a891a2a6..d62ce77f6ccf 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -897,7 +897,6 @@ static struct pcisel parsesel(const char *str) { const char *ep; - const char *epbase; char *eppos; struct pcisel sel; unsigned long selarr[4]; @@ -909,30 +908,27 @@ parsesel(const char *str) else ep = str; - epbase = ep; - if (strncmp(ep, "pci", 3) == 0) { ep += 3; i = 0; - do { + while (isdigit(*ep) && i < 4) { selarr[i++] = strtoul(ep, &eppos, 10); ep = eppos; - } while ((*ep == ':' || *ep == '.') && *++ep != '\0' && i < 4); - - if (i > 2) - sel.pc_func = selarr[--i]; - else - sel.pc_func = 0; - sel.pc_dev = selarr[--i]; - sel.pc_bus = selarr[--i]; - if (i > 0) - sel.pc_domain = selarr[--i]; - else - sel.pc_domain = 0; + if (*ep == ':') { + ep++; + if (*ep == '\0') + i = 0; + } + } + if (i > 0 && *ep == '\0') { + sel.pc_func = (i > 2) ? selarr[--i] : 0; + sel.pc_dev = (i > 0) ? selarr[--i] : 0; + sel.pc_bus = (i > 0) ? selarr[--i] : 0; + sel.pc_domain = (i > 0) ? selarr[--i] : 0; + return (sel); + } } - if (*ep != '\x0' || ep == epbase) - errx(1, "cannot parse selector %s", str); - return sel; + errx(1, "cannot parse selector %s", str); } static struct pcisel |
