Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Oct 2007 05:25:44 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 127664 for review
Message-ID:  <200710180525.l9I5PiM0007020@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=127664

Change 127664 by jb@jb_freebsd1 on 2007/10/18 05:25:15

	Fix compiler warnings for WARNS=6.

Affected files ...

.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/alist.c#4 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/ctf.c#10 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c#6 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/ctftools.h#6 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c#3 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/hash.c#6 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/iidesc.c#4 edit

Differences ...

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/alist.c#4 (text) ====

@@ -52,16 +52,19 @@
 } alist_el_t;
 
 static int
-alist_hash(int nbuckets, alist_el_t *el)
+alist_hash(int nbuckets, void *arg)
 {
+	alist_el_t *el = arg;
 	uintptr_t num = (uintptr_t)el->ale_name;
 
 	return (num % nbuckets);
 }
 
 static int
-alist_cmp(alist_el_t *el1, alist_el_t *el2)
+alist_cmp(void *arg1, void *arg2)
 {
+	alist_el_t *el1 = arg1;
+	alist_el_t *el2 = arg2;
 	return ((uintptr_t)el1->ale_name != (uintptr_t)el2->ale_name);
 }
 
@@ -84,12 +87,14 @@
 alist_new(void (*namefree)(void *), void (*valfree)(void *))
 {
 	return (alist_xnew(ALIST_HASH_SIZE, namefree, valfree,
-	    (int (*)())alist_hash, (int (*)())alist_cmp));
+	    alist_hash, alist_cmp));
 }
 
 static void
-alist_free_cb(alist_el_t *el, alist_t *alist)
+alist_free_cb(void *arg1, void *arg2)
 {
+	alist_el_t *el = arg1;
+	alist_t *alist = arg2;
 	if (alist->al_namefree)
 		alist->al_namefree(el->ale_name);
 	if (alist->al_valfree)
@@ -100,7 +105,7 @@
 void
 alist_free(alist_t *alist)
 {
-	hash_free(alist->al_elements, (void (*)())alist_free_cb, alist);
+	hash_free(alist->al_elements, alist_free_cb, alist);
 	free(alist);
 }
 
@@ -136,8 +141,10 @@
 } alist_iter_data_t;
 
 static int
-alist_iter_cb(alist_el_t *el, alist_iter_data_t *aid)
+alist_iter_cb(void *arg1, void *arg2)
 {
+	alist_el_t *el = arg1;
+	alist_iter_data_t *aid = arg2;
 	return (aid->aid_func(el->ale_name, el->ale_value, aid->aid_priv));
 }
 
@@ -149,7 +156,7 @@
 	aid.aid_func = func;
 	aid.aid_priv = private;
 
-	return (hash_iter(alist->al_elements, (int (*)())alist_iter_cb, &aid));
+	return (hash_iter(alist->al_elements, alist_iter_cb, &aid));
 }
 
 /*
@@ -187,7 +194,7 @@
 static int
 alist_dump_cb(void *node, void *private)
 {
-	int (*printer)(void *, void *) = (int (*)())private;
+	int (*printer)(void *, void *) = private;
 	alist_el_t *el = node;
 
 	printer(el->ale_name, el->ale_value);

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/ctf.c#10 (text) ====

@@ -66,7 +66,7 @@
 
 /*PRINTFLIKE1*/
 static void
-parseterminate(char *fmt, ...)
+parseterminate(const char *fmt, ...)
 {
 	static char msgbuf[1024]; /* sigh */
 	va_list ap;
@@ -78,7 +78,7 @@
 	terminate("%s: %s\n", curfile, msgbuf);
 }
 
-void
+static void
 ctf_buf_grow(ctf_buf_t *b)
 {
 	off_t ptroff = b->ctb_ptr - b->ctb_base;
@@ -89,7 +89,7 @@
 	b->ctb_ptr = b->ctb_base + ptroff;
 }
 
-ctf_buf_t *
+static ctf_buf_t *
 ctf_buf_new(void)
 {
 	ctf_buf_t *b = xcalloc(sizeof (ctf_buf_t));
@@ -100,7 +100,7 @@
 	return (b);
 }
 
-void
+static void
 ctf_buf_free(ctf_buf_t *b)
 {
 	strtab_destroy(&b->ctb_strtab);
@@ -108,14 +108,14 @@
 	free(b);
 }
 
-uint_t
+static uint_t
 ctf_buf_cur(ctf_buf_t *b)
 {
 	return (b->ctb_ptr - b->ctb_base);
 }
 
-void
-ctf_buf_write(ctf_buf_t *b, const void *p, size_t n)
+static void
+ctf_buf_write(ctf_buf_t *b, void const *p, size_t n)
 {
 	size_t len;
 
@@ -127,14 +127,16 @@
 		bcopy(p, b->ctb_ptr, len);
 		b->ctb_ptr += len;
 
-		p = (char *)p + len;
+		p = (char const *)p + len;
 		n -= len;
 	}
 }
 
 static int
-write_label(labelent_t *le, ctf_buf_t *b)
+write_label(void *arg1, void *arg2)
 {
+	labelent_t *le = arg1;
+	ctf_buf_t *b = arg2;
 	ctf_lblent_t ctl;
 
 	ctl.ctl_label = strtab_insert(&b->ctb_strtab, le->le_name);
@@ -220,8 +222,10 @@
 }
 
 static int
-write_type(tdesc_t *tp, ctf_buf_t *b)
+write_type(void *arg1, void *arg2)
 {
+	tdesc_t *tp = arg1;
+	ctf_buf_t *b = arg2;
 	elist_t *ep;
 	mlist_t *mp;
 	intr_t *ip;
@@ -392,7 +396,7 @@
 		ctt.ctt_type = tp->t_fndef->fn_ret->t_id;
 		write_unsized_type_rec(b, &ctt);
 
-		for (i = 0; i < tp->t_fndef->fn_nargs; i++) {
+		for (i = 0; i < (int) tp->t_fndef->fn_nargs; i++) {
 			id = tp->t_fndef->fn_args[i]->t_id;
 			ctf_buf_write(b, &id, sizeof (id));
 		}
@@ -457,14 +461,14 @@
 }
 
 static ssize_t
-compress_buffer(const void *buf, size_t n, void *data)
+compress_buffer(void *buf, size_t n, void *data)
 {
 	resbuf_t *rb = (resbuf_t *)data;
 	int rc;
 
 	rb->rb_zstr.next_out = (Bytef *)rb->rb_ptr;
 	rb->rb_zstr.avail_out = rb->rb_size - (rb->rb_ptr - rb->rb_base);
-	rb->rb_zstr.next_in = (Bytef *)buf;
+	rb->rb_zstr.next_in = buf;
 	rb->rb_zstr.avail_in = n;
 
 	while (rb->rb_zstr.avail_in) {
@@ -526,7 +530,7 @@
 }
 
 static ssize_t
-bcopy_data(const void *buf, size_t n, void *data)
+bcopy_data(void *buf, size_t n, void *data)
 {
 	caddr_t *posp = (caddr_t *)data;
 	bcopy(buf, *posp, n);
@@ -601,7 +605,7 @@
 	    iiburst->iib_td->td_parname);
 
 	h.cth_lbloff = 0;
-	(void) list_iter(iiburst->iib_td->td_labels, (int (*)())write_label,
+	(void) list_iter(iiburst->iib_td->td_labels, write_label,
 	    buf);
 
 	pad_buffer(buf, 2);
@@ -616,7 +620,7 @@
 
 	pad_buffer(buf, 4);
 	h.cth_typeoff = ctf_buf_cur(buf);
-	(void) list_iter(iiburst->iib_types, (int (*)())write_type, buf);
+	(void) list_iter(iiburst->iib_types, write_type, buf);
 
 	debug(2, "CTF wrote %d types\n", list_count(iiburst->iib_types));
 
@@ -637,7 +641,7 @@
 	return (outbuf);
 }
 
-void
+static void
 get_ctt_size(ctf_type_t *ctt, size_t *sizep, size_t *incrementp)
 {
 	if (ctt->ctt_size == CTF_LSIZE_SENT) {
@@ -727,7 +731,7 @@
 	caddr_t sbuf = ctfdata + h->cth_stroff;
 	size_t bufsz = h->cth_objtoff - h->cth_lbloff;
 	int lastidx = 0, baseidx = -1;
-	char *baselabel;
+	char *baselabel = NULL;
 	ctf_lblent_t *ctl;
 
 	/* LINTED - pointer alignment */

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c#6 (text) ====

@@ -46,7 +46,7 @@
 const  char *progname;
 int debug_level = DEBUG_LEVEL;
 
-static const char *infile = NULL;
+static char *infile = NULL;
 static const char *outfile = NULL;
 static int dynsym;
 
@@ -79,10 +79,10 @@
 }
 
 static int
-file_read(tdata_t *td, const char *filename, int ignore_non_c)
+file_read(tdata_t *td, char *filename, int ignore_non_c)
 {
-	typedef int (*reader_f)(tdata_t *, Elf *, const char *);
-	static const reader_f readers[] = {
+	typedef int (*reader_f)(tdata_t *, Elf *, char *);
+	static reader_f readers[] = {
 		stabs_read,
 		dw_read,
 		NULL
@@ -149,7 +149,7 @@
 main(int argc, char **argv)
 {
 	tdata_t *filetd, *mstrtd;
-	char *label = NULL;
+	const char *label = NULL;
 	int verbose = 0;
 	int ignore_non_c = 0;
 	int keep_stabs = 0;
@@ -253,7 +253,6 @@
 		write_ctf(mstrtd, infile, outfile, dynsym | keep_stabs);
 	} else {
 		char *tmpname = mktmpname(infile, ".ctf");
-
 		write_ctf(mstrtd, infile, tmpname, dynsym | keep_stabs);
 		if (rename(tmpname, infile) != 0)
 			terminate("Couldn't rename temp file %s", tmpname);

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/ctftools.h#6 (text) ====

@@ -91,7 +91,7 @@
 extern const char *progname;
 extern int debug_level;
 extern int debug_parse;
-extern const char *curhdr;
+extern char *curhdr;
 
 /*
  * This is a partial copy of the stab.h that DevPro includes with their
@@ -354,11 +354,11 @@
 iidesc_t *iidesc_new(char *);
 int iidesc_hash(int, void *);
 void iter_iidescs_by_name(tdata_t *, const char *,
-    int (*)(iidesc_t *, void *), void *);
+    int (*)(void *, void *), void *);
 iidesc_t *iidesc_dup(iidesc_t *);
 iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *);
 void iidesc_add(hash_t *, iidesc_t *);
-void iidesc_free(iidesc_t *, void *);
+void iidesc_free(void *, void *);
 int iidesc_count_type(void *, void *);
 void iidesc_stats(hash_t *);
 int iidesc_dump(iidesc_t *);
@@ -404,10 +404,10 @@
 void resolve_typed_bitfields(void);
 
 /* stabs.c */
-int stabs_read(tdata_t *, Elf *, const char *);
+int stabs_read(tdata_t *, Elf *, char *);
 
 /* dwarf.c */
-int dw_read(tdata_t *, Elf *, const char *);
+int dw_read(tdata_t *, Elf *, char *);
 const char *dw_tag2str(uint_t);
 
 /* tdata.c */
@@ -422,7 +422,7 @@
 int tdesc_layouthash(int, void *);
 int tdesc_layoutcmp(void *, void *);
 void tdesc_free(tdesc_t *);
-void tdata_label_add(tdata_t *, char *, int);
+void tdata_label_add(tdata_t *, const char *, int);
 labelent_t *tdata_label_top(tdata_t *);
 int tdata_label_find(tdata_t *, char *);
 void tdata_label_free(tdata_t *);
@@ -434,13 +434,17 @@
 int findelfsecidx(Elf *, const char *, const char *);
 size_t elf_ptrsz(Elf *);
 char *mktmpname(const char *, const char *);
-void terminate(char *, ...);
-void aborterr(char *, ...);
-void set_terminate_cleanup(void (*)());
+void terminate(const char *, ...);
+void aborterr(const char *, ...);
+void set_terminate_cleanup(void (*)(void));
 void elfterminate(const char *, const char *, ...);
-void warning(char *, ...);
-void vadebug(int, char *, va_list);
-void debug(int, char *, ...);
+void warning(const char *, ...);
+void vadebug(int, const char *, va_list);
+void debug(int, const char *, ...);
+
+
+void watch_dump(int);
+void watch_set(void *, int);
 
 #ifdef __cplusplus
 }

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c#3 (text+ko) ====

@@ -52,17 +52,17 @@
 static void
 fix_ptrptr_to_struct(tdata_t *td)
 {
-	char *strs[2] = { "as", "fdbuffer" };
-	char *mems[2] = { "a_objectdir", "fd_shadow" };
-	char *acts[2] = { "vnode", "page" };
-	char *tgts[2] = { "vnode_t", "page_t" };
+	const char *strs[2] = { "as", "fdbuffer" };
+	const char *mems[2] = { "a_objectdir", "fd_shadow" };
+	const char *acts[2] = { "vnode", "page" };
+	const char *tgts[2] = { "vnode_t", "page_t" };
 	tdesc_t *str;
 	tdesc_t *act, *tgt;
 	tdesc_t *p1, *p2;
 	mlist_t *ml;
 	int i;
 
-	for (i = 0; i < sizeof (strs) / sizeof (strs[0]); i++) {
+	for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
 		if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
 			continue;
 
@@ -106,8 +106,8 @@
 static void
 fix_ptr_to_struct(tdata_t *td)
 {
-	char *strs[2] = { "vmem", "id_space" };
-	char *mems[2] = { NULL, "is_vmem" };
+	const char *strs[2] = { "vmem", "id_space" };
+	const char *mems[2] = { NULL, "is_vmem" };
 	tdesc_t *ptr = NULL;
 	tdesc_t *str, *vmt;
 	mlist_t *ml;
@@ -116,7 +116,7 @@
 	if ((vmt = lookupname("vmem_t")) == NULL || vmt->t_type != TYPEDEF)
 		return;
 
-	for (i = 0; i < sizeof (strs) / sizeof (strs[0]); i++) {
+	for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
 		if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
 			continue;
 
@@ -163,8 +163,10 @@
 };
 
 static int
-matching_iidesc(iidesc_t *iidesc, struct match *match)
+matching_iidesc(void *arg1, void *arg2)
 {
+	iidesc_t *iidesc = arg1;
+	struct match *match = arg2;
 	if (!streq(iidesc->ii_name, match->m_name))
 		return (0);
 
@@ -176,10 +178,10 @@
 }
 
 static tdesc_t *
-lookup_tdesc(tdata_t *td, const char *name)
+lookup_tdesc(tdata_t *td, char const *name)
 {
 	struct match match = { NULL, name };
-	iter_iidescs_by_name(td, name, (int (*)())matching_iidesc, &match);
+	iter_iidescs_by_name(td, name, matching_iidesc, &match);
 	return (match.m_ret);
 }
 

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/hash.c#6 (text) ====

@@ -50,7 +50,7 @@
 
 struct hash_data {
 	hash_t *hd_hash;
-	int (*hd_fun)();
+	int (*hd_fun)(void *, void *);
 	void *hd_key;
 	void *hd_private;
 
@@ -58,13 +58,14 @@
 };
 
 static int
-hash_def_hash(int nbuckets, uintptr_t data)
+hash_def_hash(int nbuckets, void *arg)
 {
+	uintptr_t data = (uintptr_t) arg;
 	return (data % nbuckets);
 }
 
 static int
-hash_def_cmp(uintptr_t d1, uintptr_t d2)
+hash_def_cmp(void *d1, void *d2)
 {
 	return (d1 != d2);
 }
@@ -96,8 +97,8 @@
 	hash = xmalloc(sizeof (hash_t));
 	hash->h_buckets = xcalloc(sizeof (list_t *) * nbuckets);
 	hash->h_nbuckets = nbuckets;
-	hash->h_hashfn = hashfn ? hashfn : (int (*)())hash_def_hash;
-	hash->h_cmp = cmp ? cmp : (int (*)())hash_def_cmp;
+	hash->h_hashfn = hashfn ? hashfn : hash_def_hash;
+	hash->h_cmp = cmp ? cmp : hash_def_cmp;
 
 	return (hash);
 }
@@ -124,8 +125,9 @@
 }
 
 static int
-hash_remove_cb(void *key1, void *key2, hash_t *hash)
+hash_remove_cb(void *key1, void *key2, void *arg)
 {
+	hash_t *hash = arg;
 	return (hash->h_cmp(key1, key2));
 }
 
@@ -135,7 +137,7 @@
 	int bucket = hash->h_hashfn(hash->h_nbuckets, key);
 
 	(void) list_remove(&hash->h_buckets[bucket], key,
-	    (int (*)())hash_remove_cb, hash);
+	    hash_remove_cb, hash);
 }
 
 int
@@ -148,8 +150,9 @@
 }
 
 static int
-hash_find_list_cb(void *node, struct hash_data *hd)
+hash_find_list_cb(void *node, void *arg)
 {
+	struct hash_data *hd = arg;
 	int cbrc;
 	int rc = 0;
 
@@ -174,14 +177,15 @@
 	hd.hd_key = key;
 	hd.hd_private = private;
 
-	return (list_iter(hash->h_buckets[bucket], (int (*)())hash_find_list_cb,
+	return (list_iter(hash->h_buckets[bucket], hash_find_list_cb,
 	    &hd));
 }
 
 /* stop on first match */
 static int
-hash_find_first_cb(void *node, struct hash_data *hd)
+hash_find_first_cb(void *node, void *arg)
 {
+	struct hash_data *hd = arg;
 	if (hd->hd_hash->h_cmp(hd->hd_key, node) == 0) {
 		hd->hd_ret = node;
 		return (-1);
@@ -200,7 +204,7 @@
 	hd.hd_fun = hash_find_first_cb;
 	hd.hd_key = key;
 
-	ret = hash_match(hash, key, (int (*)())hash_find_first_cb, &hd);
+	ret = hash_match(hash, key, hash_find_first_cb, &hd);
 	if (ret && value)
 		*value = hd.hd_ret;
 

==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/iidesc.c#4 (text) ====

@@ -68,8 +68,10 @@
 }
 
 static int
-iidesc_cmp(iidesc_t *src, iidesc_find_t *find)
+iidesc_cmp(void *arg1, void *arg2)
 {
+	iidesc_t *src = arg1;
+	iidesc_find_t *find = arg2;
 	iidesc_t *tgt = find->iif_tgt;
 
 	if (src->ii_type != tgt->ii_type ||
@@ -89,7 +91,7 @@
 	find.iif_tgt = new;
 	find.iif_ret = NULL;
 
-	(void) hash_match(hash, new, (int (*)())iidesc_cmp, &find);
+	(void) hash_match(hash, new, iidesc_cmp, &find);
 
 	if (find.iif_ret != NULL) {
 		iidesc_t *old = find.iif_ret;
@@ -107,13 +109,14 @@
 }
 
 void
-iter_iidescs_by_name(tdata_t *td, const char *name,
-    int (*func)(iidesc_t *, void *), void *data)
+iter_iidescs_by_name(tdata_t *td, char const *name,
+    int (*func)(void *, void *), void *data)
 {
 	iidesc_t tmpdesc;
-	bzero(&tmpdesc, sizeof (iidesc_t));
-	tmpdesc.ii_name = (char *)name;
-	(void) hash_match(td->td_iihash, &tmpdesc, (int (*)())func, data);
+	bzero(&tmpdesc, sizeof(tmpdesc));
+	tmpdesc.ii_name = xstrdup(name);
+	(void) hash_match(td->td_iihash, &tmpdesc, func, data);
+	free(tmpdesc.ii_name);
 }
 
 iidesc_t *
@@ -151,8 +154,9 @@
 
 /*ARGSUSED*/
 void
-iidesc_free(iidesc_t *idp, void *private)
+iidesc_free(void *arg, void *private __unused)
 {
+	iidesc_t *idp = arg;
 	if (idp->ii_name)
 		free(idp->ii_name);
 	if (idp->ii_nargs)



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