From a32bc35d8c1d8997de5aafa141260395bb0f675e Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Fri, 8 Jun 2012 23:43:40 +0200 Subject: [PATCH] fwcontrol(8): Raise WARNS to 6 and fix warnings. --- sys/bus/firewire/fwcrom.c | 8 +++--- sys/bus/firewire/iec13213.h | 3 +- usr.sbin/fwcontrol/Makefile | 1 - usr.sbin/fwcontrol/fwcontrol.c | 31 ++++++++++----------- usr.sbin/fwcontrol/fwdv.c | 51 ++++++++++++++++++---------------- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/sys/bus/firewire/fwcrom.c b/sys/bus/firewire/fwcrom.c index e8c5941178..e315df2681 100644 --- a/sys/bus/firewire/fwcrom.c +++ b/sys/bus/firewire/fwcrom.c @@ -195,7 +195,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len) struct csrtext *textleaf; u_int32_t *bp; int i, qlen; - static char *nullstr = "(null)"; + static const char *nullstr = "(null)"; if (cc->depth < 0) return; @@ -249,7 +249,7 @@ crom_crc(u_int32_t *ptr, int len) static void crom_desc_specver(u_int32_t spec, u_int32_t ver, char *buf, int len) { - char *s = NULL; + const char *s = NULL; if (spec == CSRVAL_ANSIT10 || spec == 0) { switch (ver) { @@ -299,12 +299,12 @@ crom_desc_specver(u_int32_t spec, u_int32_t ver, char *buf, int len) ksnprintf(buf, len, "%s", s); } -char * +const char * crom_desc(struct crom_context *cc, char *buf, int len) { struct csrreg *reg; struct csrdirectory *dir; - char *desc; + const char *desc; u_int16_t crc; reg = crom_get(cc); diff --git a/sys/bus/firewire/iec13213.h b/sys/bus/firewire/iec13213.h index 90553e937c..4530590a93 100644 --- a/sys/bus/firewire/iec13213.h +++ b/sys/bus/firewire/iec13213.h @@ -32,7 +32,6 @@ * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/firewire/iec13213.h,v 1.10 2003/06/16 08:29:24 simokawa Exp $ - * $DragonFly: src/sys/bus/firewire/iec13213.h,v 1.3 2004/02/05 13:32:08 joerg Exp $ */ #define STATE_CLEAR 0x0000 @@ -218,7 +217,7 @@ struct csrreg *crom_search_key(struct crom_context *, u_int8_t); int crom_has_specver(u_int32_t *, u_int32_t, u_int32_t); #ifndef _KERNEL -char *crom_desc(struct crom_context *, char *, int); +const char *crom_desc(struct crom_context *, char *, int); #endif /* For CROM build */ diff --git a/usr.sbin/fwcontrol/Makefile b/usr.sbin/fwcontrol/Makefile index 67a34c4f4c..c740728e93 100644 --- a/usr.sbin/fwcontrol/Makefile +++ b/usr.sbin/fwcontrol/Makefile @@ -3,7 +3,6 @@ PROG= fwcontrol SRCS= fwcontrol.c fwcrom.c fwdv.c MAN= fwcontrol.8 -WARNS?= 2 .PATH: ${.CURDIR}/../../sys/bus/firewire diff --git a/usr.sbin/fwcontrol/fwcontrol.c b/usr.sbin/fwcontrol/fwcontrol.c index 16312e2ea9..1287051f82 100644 --- a/usr.sbin/fwcontrol/fwcontrol.c +++ b/usr.sbin/fwcontrol/fwcontrol.c @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.1.2.8 2003/05/01 06:26:35 simokawa Exp $ - * $DragonFly: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.3 2003/08/08 04:18:44 dillon Exp $ */ #include @@ -111,7 +110,7 @@ list_dev(int fd) } static u_int32_t -read_write_quad(int fd, struct fw_eui64 eui, u_int32_t addr_lo, int read, u_int32_t data) +read_write_quad(int fd, struct fw_eui64 eui, u_int32_t addr_lo, int readmode, u_int32_t data) { struct fw_asyreq *asyreq; u_int32_t *qld, res; @@ -126,7 +125,7 @@ read_write_quad(int fd, struct fw_eui64 eui, u_int32_t addr_lo, int read, u_int3 asyreq->req.dst.eui = eui; #endif asyreq->pkt.mode.rreqq.tlrt = 0; - if (read) + if (readmode) asyreq->pkt.mode.rreqq.tcode = FWTCODE_RREQQ; else asyreq->pkt.mode.rreqq.tcode = FWTCODE_WREQQ; @@ -135,7 +134,7 @@ read_write_quad(int fd, struct fw_eui64 eui, u_int32_t addr_lo, int read, u_int3 asyreq->pkt.mode.rreqq.dest_lo = addr_lo; qld = (u_int32_t *)&asyreq->pkt; - if (!read) + if (!readmode) asyreq->pkt.mode.wreqq.data = data; if (ioctl(fd, FW_ASYREQ, asyreq) < 0) { @@ -143,7 +142,7 @@ read_write_quad(int fd, struct fw_eui64 eui, u_int32_t addr_lo, int read, u_int3 } res = qld[3]; free(asyreq); - if (read) + if (readmode) return ntohl(res); else return 0; @@ -214,7 +213,7 @@ reset_start(int fd, int node) } static void -set_pri_req(int fd, int pri_req) +set_pri_req(int fd, u_int32_t pri_req) { struct fw_devlstreq *data; struct fw_devinfo *devinfo; @@ -230,7 +229,7 @@ set_pri_req(int fd, int pri_req) reg = read_write_quad(fd, devinfo->eui, BUGET_REG, 1, 0); printf("%d %08x:%08x, %08x", devinfo->dst, devinfo->eui.hi, devinfo->eui.lo, reg); - if (reg > 0 && pri_req >= 0) { + if (reg > 0) { old = (reg & 0x3f); max = (reg & 0x3f00) >> 8; if (pri_req > max) @@ -289,8 +288,9 @@ show_crom(u_int32_t *crom_buf) { int i; struct crom_context cc; - char *desc, info[256]; - static char *key_types = "ICLD"; + const char *desc; + char info[256]; + static const char *key_types = "ICLD"; struct csrreg *reg; struct csrdirectory *dir; struct csrhdr *hdr; @@ -300,7 +300,6 @@ show_crom(u_int32_t *crom_buf) hdr = (struct csrhdr *)crom_buf; if (hdr->info_len == 1) { /* minimum ROM */ - struct csrreg *reg; reg = (struct csrreg *)hdr; printf("verndor ID: 0x%06x\n", reg->val); return; @@ -374,10 +373,10 @@ show_topology_map(int fd) struct fw_topology_map *tmap; union fw_self_id sid; int i; - static char *port_status[] = {" ", "-", "P", "C"}; - static char *pwr_class[] = {" 0W", "15W", "30W", "45W", + static const char *port_status[] = {" ", "-", "P", "C"}; + static const char *pwr_class[] = {" 0W", "15W", "30W", "45W", "-1W", "-2W", "-5W", "-9W"}; - static char *speed[] = {"S100", "S200", "S400", "S800"}; + static const char *speed[] = {"S100", "S200", "S400", "S800"}; tmap = malloc(sizeof(struct fw_topology_map)); if (tmap == NULL) return; @@ -417,13 +416,13 @@ show_topology_map(int fd) int main(int argc, char **argv) { - char devname[256]; + char devicename[256]; u_int32_t crom_buf[1024/4]; int fd, i, tmp, ch, len=1024; for (i = 0; i < 4; i++) { - snprintf(devname, sizeof(devname), "/dev/fw%d", i); - if ((fd = open(devname, O_RDWR)) >= 0) + snprintf(devicename, sizeof(devicename), "/dev/fw%d", i); + if ((fd = open(devicename, O_RDWR)) >= 0) break; } if (fd < 0) diff --git a/usr.sbin/fwcontrol/fwdv.c b/usr.sbin/fwcontrol/fwdv.c index 73ff239ac2..4447a7364c 100644 --- a/usr.sbin/fwcontrol/fwdv.c +++ b/usr.sbin/fwcontrol/fwdv.c @@ -32,8 +32,8 @@ * SUCH DAMAGE. * * $FreeBSD: src/usr.sbin/fwcontrol/fwdv.c,v 1.2.2.4 2003/04/28 03:29:18 simokawa Exp $ - * $DragonFly: src/usr.sbin/fwcontrol/fwdv.c,v 1.3 2003/08/08 04:18:44 dillon Exp $ */ + #include #include #include @@ -74,7 +74,7 @@ struct frac pad_rate[2] = { {203, 2997}, /* = (8000 - 29.97 * 250)/(29.97 * 250) */ {1, 15}, /* = (8000 - 25 * 300)/(25 * 300) */ }; -char *system_name[] = {"NTSC", "PAL"}; +const char *system_name[] = {"NTSC", "PAL"}; int frame_rate[] = {30, 25}; #define PSIZE 512 @@ -89,6 +89,9 @@ int frame_rate[] = {30, 25}; #define MAXBLOCKS (300) #define CYCLE_FRAC 0xc00 +int dvrecv(int, char *, char, int); +int dvsend(int, char *, char, int); + int dvrecv(int d, char *filename, char ich, int count) { @@ -99,7 +102,7 @@ dvrecv(int d, char *filename, char ich, int count) struct fw_pkt *pkt; char *pad, *buf; u_int32_t *ptr; - int len, tlen, npad, fd, k, m, vec, system = -1, nb; + int len, tlen, npad, fd, k, m, vec, systype = -1, nb; int nblocks[] = {250 /* NTSC */, 300 /* PAL */}; struct iovec wbuf[NPACKET_R]; @@ -185,16 +188,16 @@ again: fprintf(stderr, "(%d,%d) ", dv->sct, dv->dseq); #endif if (dv->sct == DV_SCT_HEADER && dv->dseq == 0) { - if (system < 0) { - system = ciph->fdf.dv.fs; - printf("%s\n", system_name[system]); + if (systype < 0) { + systype = ciph->fdf.dv.fs; + printf("%s\n", system_name[systype]); } /* Fix DSF bit */ - if (system == 1 && + if (systype == 1 && (dv->payload[0] & DV_DSF_12) == 0) dv->payload[0] |= DV_DSF_12; - nb = nblocks[system]; + nb = nblocks[systype]; fprintf(stderr, "%d", k%10); #if FIX_FRAME if (m > 0 && m != nb) { @@ -214,7 +217,7 @@ again: } #endif k++; - if (k % frame_rate[system] == 0) { + if (k % frame_rate[systype] == 0) { /* every second */ fprintf(stderr, "\n"); } @@ -252,7 +255,7 @@ dvsend(int d, char *filename, char ich, int count) struct dvdbc *dv; struct fw_pkt *pkt; int len, tlen, header, fd, frames, packets, vec, offset, nhdr, i; - int system=-1, pad_acc, cycle_acc, cycle, f_cycle, f_frac; + int systype=-1, pad_acc, cycle_acc=0, cycle=0, f_cycle, f_frac; struct iovec wbuf[TNBUF*2 + NEMPTY]; char *pbuf; u_int32_t iso_data, iso_empty, hdr[TNBUF + NEMPTY][3]; @@ -334,42 +337,42 @@ next: #if 0 header = (dv->sct == 0 && dv->dseq == 0); #else - header = (packets == 0 || packets % npackets[system] == 0); + header = (packets == 0 || packets % npackets[systype] == 0); #endif ciph = (struct ciphdr *)&hdr[nhdr][1]; if (header) { - if (system < 0) { - system = ((dv->payload[0] & DV_DSF_12) != 0); - printf("%s\n", system_name[system]); + if (systype < 0) { + systype = ((dv->payload[0] & DV_DSF_12) != 0); + printf("%s\n", system_name[systype]); cycle = 1; - cycle_acc = frame_cycle[system].d * cycle; + cycle_acc = frame_cycle[systype].d * cycle; } fprintf(stderr, "%d", frames % 10); frames ++; if (count > 0 && frames > count) break; - if (frames % frame_rate[system] == 0) + if (frames % frame_rate[systype] == 0) fprintf(stderr, "\n"); fflush(stderr); - f_cycle = (cycle_acc / frame_cycle[system].d) & 0xf; - f_frac = (cycle_acc % frame_cycle[system].d - * CYCLE_FRAC) / frame_cycle[system].d; + f_cycle = (cycle_acc / frame_cycle[systype].d) & 0xf; + f_frac = (cycle_acc % frame_cycle[systype].d + * CYCLE_FRAC) / frame_cycle[systype].d; #if 0 ciph->fdf.dv.cyc = htons(f_cycle << 12 | f_frac); #else ciph->fdf.dv.cyc = htons(cycle << 12 | f_frac); #endif - cycle_acc += frame_cycle[system].n; - cycle_acc %= frame_cycle[system].d * 0x10; + cycle_acc += frame_cycle[systype].n; + cycle_acc %= frame_cycle[systype].d * 0x10; } else { ciph->fdf.dv.cyc = 0xffff; } ciph->dbc = packets++ % 256; - pad_acc += pad_rate[system].n; - if (pad_acc >= pad_rate[system].d) { - pad_acc -= pad_rate[system].d; + pad_acc += pad_rate[systype].n; + if (pad_acc >= pad_rate[systype].d) { + pad_acc -= pad_rate[systype].d; bcopy(hdr[nhdr], hdr[nhdr+1], sizeof(hdr[0])); hdr[nhdr][0] = iso_empty; wbuf[vec].iov_base = (char *)hdr[nhdr]; -- 2.41.0