Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Nov 2008 22:46:29 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185033 - head/usr.sbin/dumpcis
Message-ID:  <200811172246.mAHMkTHm060067@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Mon Nov 17 22:46:29 2008
New Revision: 185033
URL: http://svn.freebsd.org/changeset/base/185033

Log:
  make this warns=5 clean

Modified:
  head/usr.sbin/dumpcis/Makefile
  head/usr.sbin/dumpcis/dumpcis.c
  head/usr.sbin/dumpcis/dumpcisfile.c
  head/usr.sbin/dumpcis/printcis.c
  head/usr.sbin/dumpcis/readcis.c
  head/usr.sbin/dumpcis/readcis.h

Modified: head/usr.sbin/dumpcis/Makefile
==============================================================================
--- head/usr.sbin/dumpcis/Makefile	Mon Nov 17 22:19:19 2008	(r185032)
+++ head/usr.sbin/dumpcis/Makefile	Mon Nov 17 22:46:29 2008	(r185033)
@@ -5,5 +5,6 @@
 PROG=	dumpcis
 MAN=	dumpcis.8
 SRCS=	main.c dumpcis.c dumpcisfile.c readcis.c printcis.c
+WARNS?=	5
 
 .include <bsd.prog.mk>

Modified: head/usr.sbin/dumpcis/dumpcis.c
==============================================================================
--- head/usr.sbin/dumpcis/dumpcis.c	Mon Nov 17 22:19:19 2008	(r185032)
+++ head/usr.sbin/dumpcis/dumpcis.c	Mon Nov 17 22:46:29 2008	(r185033)
@@ -41,34 +41,6 @@ static const char rcsid[] =
 #include <pccard/cis.h>
 #include "readcis.h"
 
-int     nocards;
-
-static void
-scan(int slot)
-{
-	int     fd;
-	char    name[64];
-	struct cis *cp;
-	struct slotstate st;
-
-	sprintf(name, CARD_DEVICE, slot);
-	fd = open(name, O_RDONLY);
-	if (fd < 0)
-		return;
-	nocards++;
-	if (ioctl(fd, PIOCGSTATE, &st))
-		err(1, "ioctl (PIOCGSTATE)");
-	if (st.state == filled) {
-		cp = readcis(fd);
-		if (cp) {
-			printf("Configuration data for card in slot %d\n",
-			    slot);
-			dumpcis(cp);
-			freecis(cp);
-		}
-	}
-}
-
 void
 dump(unsigned char *p, int sz)
 {
@@ -84,28 +56,3 @@ dump(unsigned char *p, int sz)
 		ad += 16;
 	}
 }
-
-void *
-xmalloc(int sz)
-{
-	void   *p;
-
-	sz = (sz + 7) & ~7;
-	p = malloc(sz);
-	if (p)
-		bzero(p, sz);
-	else
-		errx(1, "malloc");
-	return (p);
-}
-
-int
-dumpcis_main(int argc, char **argv)
-{
-	int     node;
-
-	for (node = 0; node < 8; node++)
-		scan(node);
-	printf("%d slots found\n", nocards);
-	return 0;
-}

Modified: head/usr.sbin/dumpcis/dumpcisfile.c
==============================================================================
--- head/usr.sbin/dumpcis/dumpcisfile.c	Mon Nov 17 22:19:19 2008	(r185032)
+++ head/usr.sbin/dumpcis/dumpcisfile.c	Mon Nov 17 22:46:29 2008	(r185033)
@@ -42,8 +42,7 @@ static const char rcsid[] =
 #include "readcis.h"
 
 static void
-scanfile(name)
-	char     *name;
+scanfile(char *name)
 {
 	int     fd;
 	struct cis *cp;

Modified: head/usr.sbin/dumpcis/printcis.c
==============================================================================
--- head/usr.sbin/dumpcis/printcis.c	Mon Nov 17 22:19:19 2008	(r185032)
+++ head/usr.sbin/dumpcis/printcis.c	Mon Nov 17 22:46:29 2008	(r185033)
@@ -49,7 +49,7 @@ static const char rcsid[] =
 static void   dump_config_map(struct tuple *tp);
 static void   dump_cis_config(struct tuple *tp);
 static void   dump_other_cond(u_char *p, int len);
-static void   dump_device_desc(u_char *p, int len, char *type);
+static void   dump_device_desc(u_char *p, int len, const char *type);
 static void   dump_info_v1(u_char *p, int len);
 static void   dump_longlink_mfc(u_char *p, int len);
 static void   dump_bar(u_char *p, int len);
@@ -222,8 +222,8 @@ print_pwr_desc(u_char *p)
 {
 	int     len = 1, i;
 	u_char mask;
-	char  **expp;
-	static char *pname[] =
+	const char  **expp;
+	static const char *pname[] =
 	{"Nominal operating supply voltage",
 	 "Minimum operating supply voltage",
 	 "Maximum operating supply voltage",
@@ -233,11 +233,11 @@ print_pwr_desc(u_char *p)
 	 "Power down supply current",
 	 "Reserved"
 	};
-	static char *vexp[] =
+	static const char *vexp[] =
 	{"10uV", "100uV", "1mV", "10mV", "100mV", "1V", "10V", "100V"};
-	static char *cexp[] =
+	static const char *cexp[] =
 	{"10nA", "1uA", "10uA", "100uA", "1mA", "10mA", "100mA", "1A"};
-	static char *mant[] =
+	static const char *mant[] =
 	{"1", "1.2", "1.3", "1.5", "2", "2.5", "3", "3.5", "4", "4.5",
 	"5", "5.5", "6", "7", "8", "9"};
 
@@ -270,13 +270,13 @@ print_pwr_desc(u_char *p)
 static void
 print_ext_speed(u_char x, int scale)
 {
-	static char *mant[] =
+	static const char *mant[] =
 	{"Reserved", "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0",
 	"3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "7.0", "8.0"};
-	static char *exp[] =
+	static const char *exp[] =
 	{"1 ns", "10 ns", "100 ns", "1 us", "10 us", "100 us",
 	"1 ms", "10 ms"};
-	static char *scale_name[] =
+	static const char *scale_name[] =
 	{"None", "10", "100", "1,000", "10,000", "100,000",
 	"1,000,000", "10,000,000"};
 
@@ -290,7 +290,7 @@ print_ext_speed(u_char x, int scale)
  *	call from print_io_map(), print_mem_map()
  */
 static int
-print_num(int sz, char *fmt, u_char *p, int ofs)
+print_num(int sz, const char *fmt, u_char *p, int ofs)
 {
 	switch (sz) {
 	case 0:
@@ -695,14 +695,14 @@ dump_other_cond(u_char *p, int len)
  *		Common / Attribute memory descripter
  */
 static void
-dump_device_desc(u_char *p, int len, char *type)
+dump_device_desc(u_char *p, int len, const char *type)
 {
-	static char *un_name[] =
+	static const char *un_name[] =
 	{"512b", "2Kb", "8Kb", "32Kb", "128Kb", "512Kb", "2Mb", "reserved"};
-	static char *speed[] =
+	static const char *speed[] =
 	{"No speed", "250nS", "200nS", "150nS",
 	"100nS", "Reserved", "Reserved"};
-	static char *dev[] =
+	static const char *dev[] =
 	{"No device", "Mask ROM", "OTPROM", "UV EPROM",
 	 "EEPROM", "FLASH EEPROM", "SRAM", "DRAM",
 	 "Reserved", "Reserved", "Reserved", "Reserved",
@@ -778,7 +778,7 @@ dump_info_v1(u_char *p, int len)
 static void
 dump_func_id(u_char *p)
 {
-	static char *id[] = {
+	static const char *id[] = {
 		"Multifunction card",
 		"Memory card",
 		"Serial port/modem",
@@ -804,7 +804,7 @@ dump_func_id(u_char *p)
 static void
 dump_serial_ext(u_char *p, int len)
 {
-	static char *type[] = {
+	static const char *type[] = {
 		"", "Modem", "Data", "Fax", "Voice", "Data modem",
 		"Fax/modem", "Voice", " (Data)", " (Fax)", " (Voice)"
 	};
@@ -821,7 +821,7 @@ dump_serial_ext(u_char *p, int len)
 			goto err;
 		switch (p[1] & 0x1F) {
 		default:
-			printf("\t\tUnkn device");
+			printf("\t\tUnknown device");
 			break;
 		case 0:
 			printf("\t\t8250 UART");

Modified: head/usr.sbin/dumpcis/readcis.c
==============================================================================
--- head/usr.sbin/dumpcis/readcis.c	Mon Nov 17 22:19:19 2008	(r185032)
+++ head/usr.sbin/dumpcis/readcis.c	Mon Nov 17 22:46:29 2008	(r185033)
@@ -46,12 +46,6 @@ static const char rcsid[] =
 
 #include "readcis.h"
 
-#ifdef RATOCLAN
-static int	rex5588 = 0;
-#endif
-int isdumpcisfile = 0;
-
-static int read_attr(int, char *, int);
 static int ck_linktarget(int, off_t, int);
 static void cis_info(struct cis *, unsigned char *, int);
 static void device_desc(unsigned char *, int, struct dev_mem *);
@@ -105,6 +99,21 @@ static struct tuple_info tuple_info[] = 
 	{0, 0, 0}
 };
 
+
+static void *
+xmalloc(int sz)
+{
+	void   *p;
+
+	sz = (sz + 7) & ~7;
+	p = malloc(sz);
+	if (p)
+		bzero(p, sz);
+	else
+		errx(1, "malloc");
+	return (p);
+}
+
 /*
  *	After reading the tuples, decode the relevant ones.
  */
@@ -261,14 +270,14 @@ cis_manuf_id(struct cis *cp, unsigned ch
  *	Fills in CIS function ID.
  */
 static void
-cis_func_id(struct cis *cp, unsigned char *p, int len)
+cis_func_id(struct cis *cp, unsigned char *p, int len __unused)
 {
 	cp->func_id1 = *p++;
 	cp->func_id2 = *p++;
 }
 
 static void
-cis_network_ext(struct cis *cp, unsigned char *p, int len)
+cis_network_ext(struct cis *cp, unsigned char *p, int len __unused)
 {
 	int i;
 
@@ -288,68 +297,6 @@ cis_network_ext(struct cis *cp, unsigned
 }
 
 /*
- *	"FUJITSU LAN Card (FMV-J182)" has broken CIS
- */
-static int
-fmvj182_check(unsigned char *p)
-{
-	char    manuf[BUFSIZ], vers[BUFSIZ];
-
-	p++;			/* major version */
-	p++;			/* minor version */
-	strncpy(manuf, p, sizeof(manuf) - 1);
-	while (*p++);
-	strncpy(vers, p, sizeof(vers) - 1);
-	if (!strcmp(manuf, "FUJITSU") && !strcmp(vers, "LAN Card(FMV-J182)"))
-		return 1;
-	else
-		return 0;
-}
-
-#ifdef RATOCLAN
-/*
- *	"RATOC LAN Card (REX-5588)" has broken CIS
- */
-static int
-rex5588_check(unsigned char *p)
-{
-	char    manuf[BUFSIZ], vers[BUFSIZ];
-
-	p++;			/* major version */
-	p++;			/* minor version */
-	strncpy(manuf, p, sizeof(manuf) - 1);
-	while (*p++);
-	strncpy(vers, p, sizeof(manuf) - 1);
-	if (!strcmp(manuf, "PCMCIA LAN MBH10304  ES"))
-		return 1;
-	else
-		return 0;
-}
-#endif
-
-#ifdef HSSYNTH
-/*
- *	Broken CIS for "HITACHI MICROCOMPUTER SYSTEM LTD." "MSSHVPC02"
- */
-static int
-hss_check(unsigned char *p)
-{
-	char    manuf[BUFSIZ], vers[BUFSIZ];
-
-	p++;			/* major version */
-	p++;			/* minor version */
-	strncpy(manuf, p, sizeof(manuf) - 1);
-	while (*p++);
-	strncpy(vers, p, sizeof(vers) - 1);
-	if (!strcmp(manuf, "HITACHI MICROCOMPUTER SYSTEMS LTD.")
-	 && !strcmp(vers, "MSSHVPC02"))
-		return 1;
-	else
-		return 0;
-}
-#endif	/* HSSYNTH */
-
-/*
  *	device_desc - decode device descriptor.
  */
 static void
@@ -374,7 +321,7 @@ device_desc(unsigned char *p, int len, s
  *	configuration map of card control register.
  */
 static void
-config_map(struct cis *cp, unsigned char *p, int len)
+config_map(struct cis *cp, unsigned char *p, int len __unused)
 {
 	unsigned char *p1;
 	int rlen = (*p & 3) + 1;
@@ -425,7 +372,7 @@ parse_num(int sz, u_char *p, u_char **q,
  *	CIS config entry - Decode and build configuration entry.
  */
 static void
-cis_config(struct cis *cp, unsigned char *p, int len)
+cis_config(struct cis *cp, unsigned char *p, int len __unused)
 {
 	int     x;
 	int     i, j;
@@ -440,10 +387,6 @@ cis_config(struct cis *cp, unsigned char
 	} else
 		cp->conf = conf;
  	conf->id = *p & 0x3F;	/* Config index */
-#ifdef RATOCLAN
-	if (rex5588 && conf->id >= 0x08 && conf->id <= 0x1d)
-		conf->id |= 0x20;
-#endif
  	if (*p & 0x40)		/* Default flag */
 		cp->def_config = conf;
 	if (*p++ & 0x80)
@@ -638,7 +581,7 @@ read_one_tuplelist(int fd, int flags, of
 	ioctl(fd, PIOCRWFLAG, &flags);
 	lseek(fd, offs, SEEK_SET);
 	do {
-		if (read_attr(fd, &code, 1) != 1) {
+		if (read(fd, &code, 1) != 1) {
 			warn("CIS code read");
 			break;
 		}
@@ -650,7 +593,7 @@ read_one_tuplelist(int fd, int flags, of
 		if (code == CIS_END)
 			length = 0;
 		else {
-			if (read_attr(fd, &length, 1) != 1) {
+			if (read(fd, &length, 1) != 1) {
 				warn("CIS len read");
 				break;
 			}
@@ -669,7 +612,7 @@ read_one_tuplelist(int fd, int flags, of
 		if (length != 0) {
 			total += length;
 			tp->data = xmalloc(length);
-			if (read_attr(fd, tp->data, length) != length) {
+			if (read(fd, tp->data, length) != length) {
 				warn("CIS read");
 				break;
 			}
@@ -680,18 +623,6 @@ read_one_tuplelist(int fd, int flags, of
 		 * or the length is illegal.
 		 */
 		tinfo = get_tuple_info(code);
-		if (code == CIS_INFO_V1) {
-			/* Hack for broken CIS of FMV-J182 Ethernet card */
-			fmvj182 = fmvj182_check(tp->data);
-#ifdef RATOCLAN
-			/* Hack for RATOC LAN card */
-			rex5588 = rex5588_check(tp->data);
-#endif /* RATOCLAN */
-#ifdef	HSSYNTH
-			/* Hack for Hitachi Speech Synthesis card */
-			hss = hss_check(tp->data);
-#endif	/* HSSYNTH */
-		}
 		if (tinfo != NULL && (tinfo->length != 255 && tinfo->length > length)) {
 			printf("code %s ignored\n", tuple_name(code));
 			tp->code = CIS_NULL;
@@ -715,7 +646,7 @@ ck_linktarget(int fd, off_t offs, int fl
 
 	ioctl(fd, PIOCRWFLAG, &flag);
 	lseek(fd, offs, SEEK_SET);
-	if (read_attr(fd, blk, 5) != 5)
+	if (read(fd, blk, 5) != 5)
 		return (0);
 	if (blk[0] == 0x13 &&
 	    blk[1] == 0x3 &&
@@ -741,29 +672,6 @@ find_tuple_in_list(struct tuple_list *tl
 	return (tp);
 }
 
-static int
-read_attr(int fd, char *bp, int len)
-{
-	char    blk[1024], *p = blk;
-	int     i, l;
-	
-	if (isdumpcisfile)
-		return (read(fd, bp, len));
-	if (len > sizeof(blk) / 2)
-		len = sizeof(blk) / 2;
-	l = i = read(fd, blk, len * 2);
-	if (i <= 0) {
-		printf("Read return %d bytes (expected %d)\n", i, len * 2);
-		return (i);
-	}
-	while (i > 0) {
-		*bp++ = *p++;
-		p++;
-		i -= 2;
-	}
-	return (l / 2);
-}
-
 /*
  *	return table entry for code.
  */
@@ -778,7 +686,7 @@ get_tuple_info(unsigned char code)
 	return (0);
 }
 
-char *
+const char *
 tuple_name(unsigned char code)
 {
 	struct tuple_info *tp;

Modified: head/usr.sbin/dumpcis/readcis.h
==============================================================================
--- head/usr.sbin/dumpcis/readcis.h	Mon Nov 17 22:19:19 2008	(r185032)
+++ head/usr.sbin/dumpcis/readcis.h	Mon Nov 17 22:46:29 2008	(r185033)
@@ -41,7 +41,7 @@ struct tuple_list {
 };
 
 struct tuple_info {
-	char   *name;
+	const char   *name;
 	unsigned char code;
 	unsigned char length;		/* 255 means variable length */
 };
@@ -136,13 +136,13 @@ struct cis {
 			 (*((tp) + 1) << 8)  | *(tp))
 #define	tpl16(tp)	((*((tp) + 1) << 8)  | *(tp))
 
-void   *xmalloc(int);
+int	dumpcisfile_main(int, char **);
 void    dump(unsigned char *, int);
 void    dumpcis(struct cis *);
 void    freecis(struct cis *);
 struct cis *readcis(int);
 
-char   *tuple_name(unsigned char);
+const char *tuple_name(unsigned char);
 u_int   parse_num(int, u_char *, u_char **, int);
 
 int isdumpcisfile;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811172246.mAHMkTHm060067>