From a4ed9e4f78048517a2f31aab3c4a425bd609b66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Thu, 18 Feb 2016 15:23:25 +0000 Subject: [PATCH] Make WARNS=6 safe. Tested with Clang 3.7.1, GCC 4.2.1 and GCC 4.8.5 on amd64. --- usr.sbin/pciconf/Makefile | 2 -- usr.sbin/pciconf/cap.c | 10 +++++++++- usr.sbin/pciconf/pciconf.c | 17 ++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/usr.sbin/pciconf/Makefile b/usr.sbin/pciconf/Makefile index a83973354523..e288654a4d85 100644 --- a/usr.sbin/pciconf/Makefile +++ b/usr.sbin/pciconf/Makefile @@ -5,6 +5,4 @@ PROG= pciconf SRCS= pciconf.c cap.c err.c MAN= pciconf.8 -WARNS?= 3 - .include diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c index 9ab6dd17ddbd..25132cd2da8a 100644 --- a/usr.sbin/pciconf/cap.c +++ b/usr.sbin/pciconf/cap.c @@ -120,6 +120,9 @@ static void cap_vpd(int fd, struct pci_conf *p, uint8_t ptr) { + (void)fd; /* UNUSED */ + (void)p; /* UNUSED */ + (void)ptr; /* UNUSED */ printf("VPD"); } @@ -172,6 +175,7 @@ cap_pcix(int fd, struct pci_conf *p, uint8_t ptr) } if ((p->pc_hdr & PCIM_HDRTYPE) == 1) return; + max_burst_read = 0; switch (status & PCIXM_STATUS_MAX_READ) { case PCIXM_STATUS_MAX_READ_512: max_burst_read = 512; @@ -186,6 +190,7 @@ cap_pcix(int fd, struct pci_conf *p, uint8_t ptr) max_burst_read = 4096; break; } + max_splits = 0; switch (status & PCIXM_STATUS_MAX_SPLITS) { case PCIXM_STATUS_MAX_SPLITS_1: max_splits = 1; @@ -518,6 +523,9 @@ static void cap_sata(int fd, struct pci_conf *p, uint8_t ptr) { + (void)fd; /* UNUSED */ + (void)p; /* UNUSED */ + (void)ptr; /* UNUSED */ printf("SATA Index-Data Pair"); } @@ -759,7 +767,7 @@ ecap_sriov(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver) print_bar(fd, p, "iov bar ", ptr + PCIR_SRIOV_BAR(i)); } -struct { +static struct { uint16_t id; const char *name; } ecap_names[] = { diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index 194da6b3d9e8..85b5e870fed7 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -67,7 +67,7 @@ struct pci_vendor_info char *desc; }; -TAILQ_HEAD(,pci_vendor_info) pci_vendors; +static TAILQ_HEAD(,pci_vendor_info) pci_vendors; static struct pcisel getsel(const char *str); static void list_bridge(int fd, struct pci_conf *p); @@ -896,16 +896,18 @@ getdevice(const char *name) static struct pcisel parsesel(const char *str) { - char *ep = strchr(str, '@'); - char *epbase; + const char *ep; + const char *epbase; + char *eppos; struct pcisel sel; unsigned long selarr[4]; int i; - if (ep == NULL) - ep = (char *)str; - else + ep = strchr(str, '@'); + if (ep != NULL) ep++; + else + ep = str; epbase = ep; @@ -913,7 +915,8 @@ parsesel(const char *str) ep += 3; i = 0; do { - selarr[i++] = strtoul(ep, &ep, 10); + selarr[i++] = strtoul(ep, &eppos, 10); + ep = eppos; } while ((*ep == ':' || *ep == '.') && *++ep != '\0' && i < 4); if (i > 2)