PERFORCE change 127663 for review

John Birrell jb at FreeBSD.org
Wed Oct 17 22:19:38 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=127663

Change 127663 by jb at jb_freebsd1 on 2007/10/18 05:19:21

	Fix compiler warnings for WARNS=6.
	
	When reporting DIEs, display the hex value too. readelf from binutils
	reports DIEs that way (and so does my BSD libdwarf for compatibility),
	so it's helpful to make the OpenSolaris code do it too. I probably
	should have just whacked the integer values.

Affected files ...

.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/merge.c#8 edit

Differences ...

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

@@ -132,7 +132,7 @@
  * own traversal mechanism and ops vector here for those two cases.
  */
 typedef struct tdesc_ops {
-	char *name;
+	const char *name;
 	int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
 	tdesc_t *(*conjure)(tdesc_t *, int, merge_cb_data_t *);
 } tdesc_ops_t;
@@ -179,7 +179,7 @@
 static void
 add_mapping(alist_t *ta, tid_t srcid, tid_t tgtid)
 {
-	debug(3, "Adding mapping %u => %u\n", srcid, tgtid);
+	debug(3, "Adding mapping %u <%x> => %u <%x>\n", srcid, srcid, tgtid, tgtid);
 
 	assert(!alist_find(ta, (void *)(uintptr_t)srcid, NULL));
 	assert(srcid != 0 && tgtid != 0);
@@ -193,7 +193,7 @@
 	long ltgtid;
 
 	if (alist_find(ta, (void *)(uintptr_t)srcid, (void **)&ltgtid))
-		return ((int)ltgtid);
+		return ((tid_t)ltgtid);
 	else
 		return (0);
 }
@@ -216,7 +216,7 @@
 
 /*ARGSUSED2*/
 static int
-equiv_intrinsic(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
+equiv_intrinsic(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
 {
 	intr_t *si = stdp->t_intr;
 	intr_t *ti = ttdp->t_intr;
@@ -256,7 +256,7 @@
 	if (!equiv_node(fn1->fn_ret, fn2->fn_ret, ed))
 		return (0);
 
-	for (i = 0; i < fn1->fn_nargs; i++) {
+	for (i = 0; i < (int) fn1->fn_nargs; i++) {
 		if (!equiv_node(fn1->fn_args[i], fn2->fn_args[i], ed))
 			return (0);
 	}
@@ -313,7 +313,7 @@
 
 /*ARGSUSED2*/
 static int
-equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
+equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
 {
 	elist_t *el1 = stdp->t_emem;
 	elist_t *el2 = ttdp->t_emem;
@@ -335,7 +335,7 @@
 
 /*ARGSUSED*/
 static int
-equiv_assert(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
+equiv_assert(tdesc_t *stdp __unused, tdesc_t *ttdp __unused, equiv_data_t *ed __unused)
 {
 	/* foul, evil, and very bad - this is a "shouldn't happen" */
 	assert(1 == 0);
@@ -354,7 +354,7 @@
 static int
 equiv_node(tdesc_t *ctdp, tdesc_t *mtdp, equiv_data_t *ed)
 {
-	int (*equiv)();
+	int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
 	int mapping;
 
 	if (ctdp->t_emark > ed->ed_clear_mark ||
@@ -418,7 +418,8 @@
 	ed->ed_cur_mark = ed->ed_clear_mark + 1;
 
 	if (equiv_node(ctdp, mtdp, ed)) {
-		debug(3, "equiv_node matched %d %d\n", ctdp->t_id, mtdp->t_id);
+		debug(3, "equiv_node matched %d <%x> %d <%x>\n",
+		    ctdp->t_id, ctdp->t_id, mtdp->t_id, mtdp->t_id);
 		ed->ed_tgt = mtdp;
 		/* matched.  stop looking */
 		return (-1);
@@ -429,7 +430,7 @@
 
 /*ARGSUSED1*/
 static int
-map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
 {
 	merge_cb_data_t *mcd = private;
 
@@ -441,7 +442,7 @@
 
 /*ARGSUSED1*/
 static int
-map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
 {
 	merge_cb_data_t *mcd = private;
 	equiv_data_t ed;
@@ -452,7 +453,7 @@
 	ed.ed_node = ctdp;
 	ed.ed_selfuniquify = 0;
 
-	debug(3, "map_td_tree_post on %d %s\n", ctdp->t_id, tdesc_name(ctdp));
+	debug(3, "map_td_tree_post on %d <%x> %s\n", ctdp->t_id, ctdp->t_id,tdesc_name(ctdp));
 
 	if (hash_find_iter(mcd->md_parent->td_layouthash, ctdp,
 	    equiv_cb, &ed) < 0) {
@@ -460,7 +461,7 @@
 		if (ed.ed_tgt->t_type == FORWARD && ctdp->t_type != FORWARD) {
 			int id = mcd->md_tgt->td_nextid++;
 
-			debug(3, "Creating new defn type %d\n", id);
+			debug(3, "Creating new defn type %d <%x>\n", id, id);
 			add_mapping(mcd->md_ta, ctdp->t_id, id);
 			alist_add(mcd->md_fdida, (void *)(ulong_t)ed.ed_tgt,
 			    (void *)(ulong_t)id);
@@ -481,7 +482,7 @@
 	} else {
 		int id = mcd->md_tgt->td_nextid++;
 
-		debug(3, "Creating new type %d\n", id);
+		debug(3, "Creating new type %d <%x>\n", id, id);
 		add_mapping(mcd->md_ta, ctdp->t_id, id);
 		hash_add(mcd->md_tdtba, ctdp);
 	}
@@ -493,7 +494,7 @@
 
 /*ARGSUSED1*/
 static int
-map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
 {
 	merge_cb_data_t *mcd = private;
 	equiv_data_t ed;
@@ -506,8 +507,8 @@
 	ed.ed_tgt = NULL;
 
 	if (hash_find_iter(mcd->md_tdtba, ctdp, equiv_cb, &ed) < 0) {
-		debug(3, "Self check found %d in %d\n", ctdp->t_id,
-		    ed.ed_tgt->t_id);
+		debug(3, "Self check found %d <%x> in %d <%x>\n", ctdp->t_id,
+		    ctdp->t_id, ed.ed_tgt->t_id, ed.ed_tgt->t_id);
 		add_mapping(mcd->md_ta, ctdp->t_id,
 		    get_mapping(mcd->md_ta, ed.ed_tgt->t_id));
 	} else if (debug_level > 1 && hash_iter(mcd->md_tdtba,
@@ -518,12 +519,13 @@
 		 * through the entire hash.  This usually means that the hash
 		 * function is broken.
 		 */
-		aborterr("Self-unique second pass for %d (%s) == %d\n",
-		    ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id);
+		aborterr("Self-unique second pass for %d <%x> (%s) == %d <%x>\n",
+		    ctdp->t_id, ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id,
+		    ed.ed_tgt->t_id);
 	} else {
 		int id = mcd->md_tgt->td_nextid++;
 
-		debug(3, "Creating new type %d\n", id);
+		debug(3, "Creating new type %d <%x>\n", id, id);
 		add_mapping(mcd->md_ta, ctdp->t_id, id);
 		hash_add(mcd->md_tdtba, ctdp);
 	}
@@ -696,14 +698,14 @@
 	}
 
 	if ((template.t_id = get_mapping(mcd->md_ta, oldid)) == 0)
-		aborterr("failed to get mapping for tid %d\n", oldid);
+		aborterr("failed to get mapping for tid %d <%x>\n", oldid, oldid);
 
 	if (!hash_find(mcd->md_parent->td_idhash, (void *)&template,
 	    (void *)&tgt) && (!(mcd->md_flags & MCD_F_REFMERGE) ||
 	    !hash_find(mcd->md_tgt->td_idhash, (void *)&template,
 	    (void *)&tgt))) {
-		debug(3, "Remap couldn't find %d (from %d)\n", template.t_id,
-		    oldid);
+		debug(3, "Remap couldn't find %d <%x> (from %d <%x>)\n", template.t_id,
+		    template.t_id, oldid, oldid);
 		*tgtp = oldtgt;
 		list_add(mcd->md_tdtbr, tgtp);
 		return (0);
@@ -729,7 +731,7 @@
 
 /*ARGSUSED2*/
 static tdesc_t *
-conjure_intrinsic(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
+conjure_intrinsic(tdesc_t *old, int newselfid, merge_cb_data_t *mcd __unused)
 {
 	tdesc_t *new = conjure_template(old, newselfid);
 
@@ -765,7 +767,7 @@
 	if (nfn->fn_nargs > 0)
 		nfn->fn_args = xcalloc(sizeof (tdesc_t *) * ofn->fn_nargs);
 
-	for (i = 0; i < ofn->fn_nargs; i++) {
+	for (i = 0; i < (int) ofn->fn_nargs; i++) {
 		(void) remap_node(&nfn->fn_args[i], ofn->fn_args[i], old->t_id,
 		    new, mcd);
 	}
@@ -805,7 +807,7 @@
 		*nmemp = xmalloc(sizeof (mlist_t));
 		(*nmemp)->ml_offset = omem->ml_offset;
 		(*nmemp)->ml_size = omem->ml_size;
-		(*nmemp)->ml_name = xstrdup(omem->ml_name);
+		(*nmemp)->ml_name = xstrdup(omem->ml_name ? omem->ml_name : "empty omem->ml_name");
 		(void) remap_node(&((*nmemp)->ml_type), omem->ml_type,
 		    old->t_id, new, mcd);
 	}
@@ -816,7 +818,7 @@
 
 /*ARGSUSED2*/
 static tdesc_t *
-conjure_enum(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
+conjure_enum(tdesc_t *old, int newselfid, merge_cb_data_t *mcd __unused)
 {
 	tdesc_t *new = conjure_template(old, newselfid);
 	elist_t *oel, **nelp;
@@ -845,7 +847,7 @@
 
 /*ARGSUSED*/
 static tdesc_t *
-conjure_assert(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
+conjure_assert(tdesc_t *old __unused, int newselfid __unused, merge_cb_data_t *mcd __unused)
 {
 	assert(1 == 0);
 	return (NULL);
@@ -987,8 +989,9 @@
 	assert(hash_find(mcd->md_parent->td_idhash,
 	    (void *)&template, NULL) == 0);
 
-	debug(3, "trying to conjure %d %s (%d) as %d\n",
-	    oldtdp->t_type, tdesc_name(oldtdp), oldtdp->t_id, newid);
+	debug(3, "trying to conjure %d %s (%d, <%x>) as %d, <%x>\n",
+	    oldtdp->t_type, tdesc_name(oldtdp), oldtdp->t_id,
+	    oldtdp->t_id, newid, newid);
 
 	if ((newtdp = tdesc_ops[oldtdp->t_type].conjure(oldtdp, newid,
 	    mcd)) == NULL)
@@ -1049,16 +1052,16 @@
 
 	(void) hash_iter(src, merge_type_cb, mcd);
 
-	tdrc = hash_iter(mcd->md_tdtba, add_tdtba_cb, (void *)mcd);
+	tdrc = hash_iter(mcd->md_tdtba, add_tdtba_cb, mcd);
 	debug(3, "add_tdtba_cb added %d items\n", tdrc);
 
-	iirc = list_iter(*mcd->md_iitba, add_iitba_cb, (void *)mcd);
+	iirc = list_iter(*mcd->md_iitba, add_iitba_cb, mcd);
 	debug(3, "add_iitba_cb added %d items\n", iirc);
 
 	assert(list_count(*mcd->md_iitba) == 0 &&
 	    hash_count(mcd->md_tdtba) == 0);
 
-	tdrc = list_iter(*mcd->md_tdtbr, add_tdtbr_cb, (void *)mcd);
+	tdrc = list_iter(*mcd->md_tdtbr, add_tdtbr_cb, mcd);
 	debug(3, "add_tdtbr_cb added %d items\n", tdrc);
 
 	if (list_count(*mcd->md_tdtbr) != 0)


More information about the p4-projects mailing list