summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/tools
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>2008-04-26 00:54:52 +0000
committerjb <jb@FreeBSD.org>2008-04-26 00:54:52 +0000
commit52c14c7a3f5fbfa9c707a6206668a1eaa6c77a50 (patch)
treec98db398653c7c531756a3578af91819cb574281 /cddl/contrib/opensolaris/tools
parentcb8ce777270daa16660da8e87ef6a11d5bc5408f (diff)
downloadFreeBSD-src-52c14c7a3f5fbfa9c707a6206668a1eaa6c77a50.zip
FreeBSD-src-52c14c7a3f5fbfa9c707a6206668a1eaa6c77a50.tar.gz
Vendor import of the full userland contrib part of DTrace support from
OpenSolaris. This commit resets files to match the versions in the OpenSolaris tree as of 2008/04/10. The changes in this import from the previous import are the ones that will subsequently re-applied to take files off the vendor branch. This is unfortunately necessary because the Solaris developers won't allow FreeBSD support #ifdefs in their source code because that creates 'dead code' (stuff that they never compile).
Diffstat (limited to 'cddl/contrib/opensolaris/tools')
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/common/list.c4
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/common/memory.c1
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/alist.c38
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/alist.h1
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c14
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h5
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c109
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c21
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c16
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h28
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c242
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c24
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/hash.c26
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c20
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/input.c5
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/merge.c81
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/output.c61
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c34
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c12
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c42
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c18
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/util.c63
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/dump/dump.c50
26 files changed, 394 insertions, 527 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/common/list.c b/cddl/contrib/opensolaris/tools/ctf/common/list.c
index 4958f27..c01de9b 100644
--- a/cddl/contrib/opensolaris/tools/ctf/common/list.c
+++ b/cddl/contrib/opensolaris/tools/ctf/common/list.c
@@ -70,7 +70,7 @@ slist_add(list_t **list, void *data, int (*cmp)(void *, void *))
/*ARGSUSED2*/
static int
-list_defcmp(void *d1, void *d2, void *private __unused)
+list_defcmp(void *d1, void *d2, void *private)
{
return (d1 != d2);
}
@@ -135,7 +135,7 @@ list_iter(list_t *list, int (*func)(void *, void *), void *private)
/*ARGSUSED*/
static int
-list_count_cb(void *data __unused, void *private __unused)
+list_count_cb(void *data, void *private)
{
return (1);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/common/memory.c b/cddl/contrib/opensolaris/tools/ctf/common/memory.c
index e16044a..390ff12 100644
--- a/cddl/contrib/opensolaris/tools/ctf/common/memory.c
+++ b/cddl/contrib/opensolaris/tools/ctf/common/memory.c
@@ -35,7 +35,6 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include "memory.h"
static void
memory_bailout(void)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
index 8e776dc..415a6cd 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
@@ -52,19 +52,16 @@ typedef struct alist_el {
} alist_el_t;
static int
-alist_hash(int nbuckets, void *arg)
+alist_hash(int nbuckets, alist_el_t *el)
{
- alist_el_t *el = arg;
uintptr_t num = (uintptr_t)el->ale_name;
return (num % nbuckets);
}
static int
-alist_cmp(void *arg1, void *arg2)
+alist_cmp(alist_el_t *el1, alist_el_t *el2)
{
- alist_el_t *el1 = arg1;
- alist_el_t *el2 = arg2;
return ((uintptr_t)el1->ale_name != (uintptr_t)el2->ale_name);
}
@@ -87,14 +84,12 @@ alist_t *
alist_new(void (*namefree)(void *), void (*valfree)(void *))
{
return (alist_xnew(ALIST_HASH_SIZE, namefree, valfree,
- alist_hash, alist_cmp));
+ (int (*)())alist_hash, (int (*)())alist_cmp));
}
static void
-alist_free_cb(void *arg1, void *arg2)
+alist_free_cb(alist_el_t *el, alist_t *alist)
{
- alist_el_t *el = arg1;
- alist_t *alist = arg2;
if (alist->al_namefree)
alist->al_namefree(el->ale_name);
if (alist->al_valfree)
@@ -105,7 +100,7 @@ alist_free_cb(void *arg1, void *arg2)
void
alist_free(alist_t *alist)
{
- hash_free(alist->al_elements, alist_free_cb, alist);
+ hash_free(alist->al_elements, (void (*)())alist_free_cb, alist);
free(alist);
}
@@ -123,17 +118,14 @@ alist_add(alist_t *alist, void *name, void *value)
int
alist_find(alist_t *alist, void *name, void **value)
{
- alist_el_t template, *retx;
- void *ret;
+ alist_el_t template, *ret;
template.ale_name = name;
- if (!hash_find(alist->al_elements, &template, &ret))
+ if (!hash_find(alist->al_elements, &template, (void **)&ret))
return (0);
- if (value) {
- retx = ret;
- *value = retx->ale_value;
- }
+ if (value)
+ *value = ret->ale_value;
return (1);
}
@@ -144,10 +136,8 @@ typedef struct alist_iter_data {
} alist_iter_data_t;
static int
-alist_iter_cb(void *arg1, void *arg2)
+alist_iter_cb(alist_el_t *el, alist_iter_data_t *aid)
{
- alist_el_t *el = arg1;
- alist_iter_data_t *aid = arg2;
return (aid->aid_func(el->ale_name, el->ale_value, aid->aid_priv));
}
@@ -159,7 +149,7 @@ alist_iter(alist_t *alist, int (*func)(void *, void *, void *), void *private)
aid.aid_func = func;
aid.aid_priv = private;
- return (hash_iter(alist->al_elements, alist_iter_cb, &aid));
+ return (hash_iter(alist->al_elements, (int (*)())alist_iter_cb, &aid));
}
/*
@@ -181,13 +171,13 @@ alist_def_print_cb(void *key, void *value)
{
printf("Key: ");
if (alist_def_print_cb_key_int == 1)
- printf("%5lu ", (ulong_t)key);
+ printf("%5d ", (int)key);
else
printf("%s\n", (char *)key);
printf("Value: ");
if (alist_def_print_cb_value_int == 1)
- printf("%5lu\n", (ulong_t)value);
+ printf("%5d\n", (int)value);
else
printf("%s\n", (char *)key);
@@ -197,7 +187,7 @@ alist_def_print_cb(void *key, void *value)
static int
alist_dump_cb(void *node, void *private)
{
- int (*printer)(void *, void *) = private;
+ int (*printer)(void *, void *) = (int (*)())private;
alist_el_t *el = node;
printer(el->ale_name, el->ale_value);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
index 629e029..ec49df1 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
@@ -48,7 +48,6 @@ void alist_add(alist_t *, void *, void *);
int alist_find(alist_t *, void *, void **);
int alist_iter(alist_t *, int (*)(void *, void *, void *), void *);
void alist_stats(alist_t *, int);
-int alist_dump(alist_t *, int (*)(void *, void *));
#ifdef __cplusplus
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
index bc278b0..d91fbf4 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
@@ -38,9 +38,7 @@
*/
#include <pthread.h>
-#if defined(sun)
#include <synch.h>
-#endif
#include <stdio.h>
#include "barrier.h"
@@ -49,11 +47,7 @@ void
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);
-#if defined(sun)
sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
-#else
- sem_init(&bar->bar_sem, 0, 0);
-#endif
bar->bar_numin = 0;
bar->bar_nthr = nthreads;
@@ -66,11 +60,7 @@ barrier_wait(barrier_t *bar)
if (++bar->bar_numin < bar->bar_nthr) {
pthread_mutex_unlock(&bar->bar_lock);
-#if defined(sun)
sema_wait(&bar->bar_sem);
-#else
- sem_wait(&bar->bar_sem);
-#endif
return (0);
@@ -80,11 +70,7 @@ barrier_wait(barrier_t *bar)
/* reset for next use */
bar->bar_numin = 0;
for (i = 1; i < bar->bar_nthr; i++)
-#if defined(sun)
sema_post(&bar->bar_sem);
-#else
- sem_post(&bar->bar_sem);
-#endif
pthread_mutex_unlock(&bar->bar_lock);
return (1);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
index c7e6212..3a62f30 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
@@ -33,12 +33,7 @@
* APIs for the barrier synchronization primitive.
*/
-#if defined(sun)
#include <synch.h>
-#else
-#include <semaphore.h>
-typedef sem_t sema_t;
-#endif
#ifdef __cplusplus
extern "C" {
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
index 6a9d67a..91e0f61 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
@@ -66,7 +66,7 @@ struct ctf_buf {
/*PRINTFLIKE1*/
static void
-parseterminate(const char *fmt, ...)
+parseterminate(char *fmt, ...)
{
static char msgbuf[1024]; /* sigh */
va_list ap;
@@ -78,7 +78,7 @@ parseterminate(const char *fmt, ...)
terminate("%s: %s\n", curfile, msgbuf);
}
-static void
+void
ctf_buf_grow(ctf_buf_t *b)
{
off_t ptroff = b->ctb_ptr - b->ctb_base;
@@ -89,7 +89,7 @@ ctf_buf_grow(ctf_buf_t *b)
b->ctb_ptr = b->ctb_base + ptroff;
}
-static ctf_buf_t *
+ctf_buf_t *
ctf_buf_new(void)
{
ctf_buf_t *b = xcalloc(sizeof (ctf_buf_t));
@@ -100,7 +100,7 @@ ctf_buf_new(void)
return (b);
}
-static void
+void
ctf_buf_free(ctf_buf_t *b)
{
strtab_destroy(&b->ctb_strtab);
@@ -108,14 +108,14 @@ ctf_buf_free(ctf_buf_t *b)
free(b);
}
-static uint_t
+uint_t
ctf_buf_cur(ctf_buf_t *b)
{
return (b->ctb_ptr - b->ctb_base);
}
-static void
-ctf_buf_write(ctf_buf_t *b, void const *p, size_t n)
+void
+ctf_buf_write(ctf_buf_t *b, const void *p, size_t n)
{
size_t len;
@@ -127,16 +127,14 @@ ctf_buf_write(ctf_buf_t *b, void const *p, size_t n)
bcopy(p, b->ctb_ptr, len);
b->ctb_ptr += len;
- p = (char const *)p + len;
+ p = (char *)p + len;
n -= len;
}
}
static int
-write_label(void *arg1, void *arg2)
+write_label(labelent_t *le, ctf_buf_t *b)
{
- labelent_t *le = arg1;
- ctf_buf_t *b = arg2;
ctf_lblent_t ctl;
ctl.ctl_label = strtab_insert(&b->ctb_strtab, le->le_name);
@@ -222,10 +220,8 @@ write_unsized_type_rec(ctf_buf_t *b, ctf_type_t *ctt)
}
static int
-write_type(void *arg1, void *arg2)
+write_type(tdesc_t *tp, ctf_buf_t *b)
{
- tdesc_t *tp = arg1;
- ctf_buf_t *b = arg2;
elist_t *ep;
mlist_t *mp;
intr_t *ip;
@@ -396,7 +392,7 @@ write_type(void *arg1, void *arg2)
ctt.ctt_type = tp->t_fndef->fn_ret->t_id;
write_unsized_type_rec(b, &ctt);
- for (i = 0; i < (int) tp->t_fndef->fn_nargs; i++) {
+ for (i = 0; i < tp->t_fndef->fn_nargs; i++) {
id = tp->t_fndef->fn_args[i]->t_id;
ctf_buf_write(b, &id, sizeof (id));
}
@@ -461,14 +457,14 @@ compress_start(resbuf_t *rb)
}
static ssize_t
-compress_buffer(void *buf, size_t n, void *data)
+compress_buffer(const 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 = buf;
+ rb->rb_zstr.next_in = (Bytef *)buf;
rb->rb_zstr.avail_in = n;
while (rb->rb_zstr.avail_in) {
@@ -530,7 +526,7 @@ pad_buffer(ctf_buf_t *buf, int align)
}
static ssize_t
-bcopy_data(void *buf, size_t n, void *data)
+bcopy_data(const void *buf, size_t n, void *data)
{
caddr_t *posp = (caddr_t *)data;
bcopy(buf, *posp, n);
@@ -605,7 +601,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
iiburst->iib_td->td_parname);
h.cth_lbloff = 0;
- (void) list_iter(iiburst->iib_td->td_labels, write_label,
+ (void) list_iter(iiburst->iib_td->td_labels, (int (*)())write_label,
buf);
pad_buffer(buf, 2);
@@ -620,7 +616,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
pad_buffer(buf, 4);
h.cth_typeoff = ctf_buf_cur(buf);
- (void) list_iter(iiburst->iib_types, write_type, buf);
+ (void) list_iter(iiburst->iib_types, (int (*)())write_type, buf);
debug(2, "CTF wrote %d types\n", list_count(iiburst->iib_types));
@@ -641,7 +637,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
return (outbuf);
}
-static void
+void
get_ctt_size(ctf_type_t *ctt, size_t *sizep, size_t *incrementp)
{
if (ctt->ctt_size == CTF_LSIZE_SENT) {
@@ -661,8 +657,8 @@ count_types(ctf_header_t *h, caddr_t data)
dptr = data + h->cth_typeoff;
while (dptr < data + h->cth_stroff) {
- void *v = (void *) dptr;
- ctf_type_t *ctt = v;
+ /* LINTED - pointer alignment */
+ ctf_type_t *ctt = (ctf_type_t *)dptr;
size_t vlen = CTF_INFO_VLEN(ctt->ctt_info);
size_t size, increment;
@@ -731,11 +727,11 @@ resurrect_labels(ctf_header_t *h, tdata_t *td, caddr_t ctfdata, char *matchlbl)
caddr_t sbuf = ctfdata + h->cth_stroff;
size_t bufsz = h->cth_objtoff - h->cth_lbloff;
int lastidx = 0, baseidx = -1;
- char *baselabel = NULL;
+ char *baselabel;
ctf_lblent_t *ctl;
- void *v = (void *) buf;
- for (ctl = v; (caddr_t)ctl < buf + bufsz; ctl++) {
+ /* LINTED - pointer alignment */
+ for (ctl = (ctf_lblent_t *)buf; (caddr_t)ctl < buf + bufsz; ctl++) {
char *label = sbuf + ctl->ctl_label;
lastidx = ctl->ctl_typeidx;
@@ -779,8 +775,8 @@ resurrect_objects(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
symit_reset(si);
for (dptr = buf; dptr < buf + bufsz; dptr += 2) {
- void *v = (void *) dptr;
- ushort_t id = *((ushort_t *)v);
+ /* LINTED - pointer alignment */
+ ushort_t id = *((ushort_t *)dptr);
iidesc_t *ii;
GElf_Sym *sym;
@@ -827,8 +823,8 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
symit_reset(si);
while (dptr < buf + bufsz) {
- void *v = (void *) dptr;
- info = *((ushort_t *)v);
+ /* LINTED - pointer alignment */
+ info = *((ushort_t *)dptr);
dptr += 2;
if (!(sym = symit_next(si, STT_FUNC)) && info != 0)
@@ -840,8 +836,8 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
continue;
}
- v = (void *) dptr;
- retid = *((ushort_t *)v);
+ /* LINTED - pointer alignment */
+ retid = *((ushort_t *)dptr);
dptr += 2;
if (retid >= tdsize)
@@ -860,8 +856,8 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
xmalloc(sizeof (tdesc_t *) * ii->ii_nargs);
for (i = 0; i < ii->ii_nargs; i++, dptr += 2) {
- v = (void *) dptr;
- ushort_t id = *((ushort_t *)v);
+ /* LINTED - pointer alignment */
+ ushort_t id = *((ushort_t *)dptr);
if (id >= tdsize)
parseterminate("Reference to invalid type %d",
id);
@@ -921,8 +917,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
if (tid >= tdsize)
parseterminate("Reference to invalid type %d", tid);
- void *v = (void *) dptr;
- ctt = v;
+ /* LINTED - pointer alignment */
+ ctt = (ctf_type_t *)dptr;
get_ctt_size(ctt, &size, &increment);
dptr += increment;
@@ -946,8 +942,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_type = INTRINSIC;
tdp->t_size = size;
- v = (void *) dptr;
- data = *((uint_t *)v);
+ /* LINTED - pointer alignment */
+ data = *((uint_t *)dptr);
dptr += sizeof (uint_t);
encoding = CTF_INT_ENCODING(data);
@@ -973,8 +969,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_type = INTRINSIC;
tdp->t_size = size;
- v = (void *) dptr;
- data = *((uint_t *)v);
+ /* LINTED - pointer alignment */
+ data = *((uint_t *)dptr);
dptr += sizeof (uint_t);
ip = xcalloc(sizeof (intr_t));
@@ -994,8 +990,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_type = ARRAY;
tdp->t_size = size;
- v = (void *) dptr;
- cta = v;
+ /* LINTED - pointer alignment */
+ cta = (ctf_array_t *)dptr;
dptr += sizeof (ctf_array_t);
tdp->t_ardef = xmalloc(sizeof (ardef_t));
@@ -1012,8 +1008,9 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
if (size < CTF_LSTRUCT_THRESH) {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
- v = (void *) dptr;
- ctf_member_t *ctm = v;
+ /* LINTED - pointer alignment */
+ ctf_member_t *ctm = (ctf_member_t *)
+ dptr;
dptr += sizeof (ctf_member_t);
*mpp = xmalloc(sizeof (mlist_t));
@@ -1026,8 +1023,9 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
} else {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
- v = (void *) dptr;
- ctf_lmember_t *ctlm = v;
+ /* LINTED - pointer alignment */
+ ctf_lmember_t *ctlm = (ctf_lmember_t *)
+ dptr;
dptr += sizeof (ctf_lmember_t);
*mpp = xmalloc(sizeof (mlist_t));
@@ -1050,8 +1048,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
for (i = 0, epp = &tdp->t_emem; i < vlen;
i++, epp = &((*epp)->el_next)) {
- v = (void *) dptr;
- cte = v;
+ /* LINTED - pointer alignment */
+ cte = (ctf_enum_t *)dptr;
dptr += sizeof (ctf_enum_t);
*epp = xmalloc(sizeof (elist_t));
@@ -1086,8 +1084,9 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_fndef = xcalloc(sizeof (fndef_t));
tdp->t_fndef->fn_ret = tdarr[ctt->ctt_type];
- v = (void *) (dptr + (sizeof (ushort_t) * (vlen - 1)));
- if (vlen > 0 && *(ushort_t *)v == 0)
+ /* LINTED - pointer alignment */
+ if (vlen > 0 && *(ushort_t *)(dptr +
+ (sizeof (ushort_t) * (vlen - 1))) == 0)
tdp->t_fndef->fn_vargs = 1;
tdp->t_fndef->fn_nargs = vlen - tdp->t_fndef->fn_vargs;
@@ -1095,8 +1094,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
vlen - tdp->t_fndef->fn_vargs);
for (i = 0; i < vlen; i++) {
- v = (void *) dptr;
- argid = *(ushort_t *)v;
+ /* LINTED - pointer alignment */
+ argid = *(ushort_t *)dptr;
dptr += sizeof (ushort_t);
if (argid != 0)
@@ -1197,7 +1196,7 @@ decompress_ctf(caddr_t cbuf, size_t cbufsz, caddr_t dbuf, size_t dbufsz)
(rc = inflate(&zstr, Z_NO_FLUSH)) != Z_STREAM_END ||
(rc = inflateEnd(&zstr)) != Z_OK) {
warning("CTF decompress zlib error %s\n", zError(rc));
- return (0);
+ return (NULL);
}
debug(3, "reflated %lu bytes to %lu, pointer at %d\n",
@@ -1226,8 +1225,8 @@ ctf_load(char *file, caddr_t buf, size_t bufsz, symit_data_t *si, char *label)
if (bufsz < sizeof (ctf_header_t))
parseterminate("Corrupt CTF - short header");
- void *v = (void *) buf;
- h = v;
+ /* LINTED - pointer alignment */
+ h = (ctf_header_t *)buf;
buf += sizeof (ctf_header_t);
bufsz -= sizeof (ctf_header_t);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
index efe6c27..756549e 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
@@ -46,7 +46,7 @@
const char *progname;
int debug_level = DEBUG_LEVEL;
-static char *infile = NULL;
+static const char *infile = NULL;
static const char *outfile = NULL;
static int dynsym;
@@ -64,12 +64,10 @@ usage(void)
static void
terminate_cleanup(void)
{
-#if !defined(__FreeBSD__)
if (!outfile) {
fprintf(stderr, "Removing %s\n", infile);
unlink(infile);
}
-#endif
}
static void
@@ -79,10 +77,10 @@ handle_sig(int sig)
}
static int
-file_read(tdata_t *td, char *filename, int ignore_non_c)
+file_read(tdata_t *td, const char *filename, int ignore_non_c)
{
- typedef int (*reader_f)(tdata_t *, Elf *, char *);
- static reader_f readers[] = {
+ typedef int (*reader_f)(tdata_t *, Elf *, const char *);
+ static const reader_f readers[] = {
stabs_read,
dw_read,
NULL
@@ -149,17 +147,15 @@ int
main(int argc, char **argv)
{
tdata_t *filetd, *mstrtd;
- const char *label = NULL;
+ char *label = NULL;
int verbose = 0;
int ignore_non_c = 0;
int keep_stabs = 0;
int c;
-#if defined(sun)
sighold(SIGINT);
sighold(SIGQUIT);
sighold(SIGTERM);
-#endif
progname = basename(argv[0]);
@@ -221,15 +217,9 @@ main(int argc, char **argv)
*/
set_terminate_cleanup(terminate_cleanup);
-#if defined(sun)
sigset(SIGINT, handle_sig);
sigset(SIGQUIT, handle_sig);
sigset(SIGTERM, handle_sig);
-#else
- signal(SIGINT, handle_sig);
- signal(SIGQUIT, handle_sig);
- signal(SIGTERM, handle_sig);
-#endif
filetd = tdata_new();
@@ -253,6 +243,7 @@ main(int argc, char **argv)
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);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
index 546dcdf..2def4904 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
@@ -176,22 +176,16 @@
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
-#if defined(sun)
#include <synch.h>
-#endif
#include <signal.h>
#include <libgen.h>
#include <string.h>
#include <errno.h>
-#if defined(sun)
#include <alloca.h>
-#endif
#include <sys/param.h>
#include <sys/types.h>
#include <sys/mman.h>
-#if defined(sun)
#include <sys/sysconf.h>
-#endif
#include "ctf_headers.h"
#include "ctftools.h"
@@ -232,7 +226,6 @@ usage(void)
progname, progname);
}
-#if defined(sun)
static void
bigheap(void)
{
@@ -280,7 +273,6 @@ bigheap(void)
(void) memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mha, 0, 0);
}
-#endif
static void
finalize_phase_one(workqueue_t *wq)
@@ -603,12 +595,10 @@ terminate_cleanup(void)
if (outfile == NULL)
return;
-#if !defined(__FreeBSD__)
if (dounlink) {
fprintf(stderr, "Removing %s\n", outfile);
unlink(outfile);
}
-#endif
}
static void
@@ -707,15 +697,9 @@ start_threads(workqueue_t *wq)
wq);
}
-#if defined(sun)
sigset(SIGINT, handle_sig);
sigset(SIGQUIT, handle_sig);
sigset(SIGTERM, handle_sig);
-#else
- signal(SIGINT, handle_sig);
- signal(SIGQUIT, handle_sig);
- signal(SIGTERM, handle_sig);
-#endif
pthread_sigmask(SIG_UNBLOCK, &sets, NULL);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
index 52bbf44..991f3bc 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
@@ -91,7 +91,7 @@ extern "C" {
extern const char *progname;
extern int debug_level;
extern int debug_parse;
-extern char *curhdr;
+extern const char *curhdr;
/*
* This is a partial copy of the stab.h that DevPro includes with their
@@ -354,11 +354,11 @@ tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *);
iidesc_t *iidesc_new(char *);
int iidesc_hash(int, void *);
void iter_iidescs_by_name(tdata_t *, const char *,
- int (*)(void *, void *), void *);
+ int (*)(iidesc_t *, 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(void *, void *);
+void iidesc_free(iidesc_t *, void *);
int iidesc_count_type(void *, void *);
void iidesc_stats(hash_t *);
int iidesc_dump(iidesc_t *);
@@ -404,10 +404,10 @@ void check_hash(void);
void resolve_typed_bitfields(void);
/* stabs.c */
-int stabs_read(tdata_t *, Elf *, char *);
+int stabs_read(tdata_t *, Elf *, const char *);
/* dwarf.c */
-int dw_read(tdata_t *, Elf *, char *);
+int dw_read(tdata_t *, Elf *, const char *);
const char *dw_tag2str(uint_t);
/* tdata.c */
@@ -422,7 +422,7 @@ int tdesc_namecmp(void *, void *);
int tdesc_layouthash(int, void *);
int tdesc_layoutcmp(void *, void *);
void tdesc_free(tdesc_t *);
-void tdata_label_add(tdata_t *, const char *, int);
+void tdata_label_add(tdata_t *, char *, int);
labelent_t *tdata_label_top(tdata_t *);
int tdata_label_find(tdata_t *, char *);
void tdata_label_free(tdata_t *);
@@ -434,17 +434,13 @@ int streq(const char *, const char *);
int findelfsecidx(Elf *, const char *, const char *);
size_t elf_ptrsz(Elf *);
char *mktmpname(const char *, const char *);
-void terminate(const char *, ...);
-void aborterr(const char *, ...);
-void set_terminate_cleanup(void (*)(void));
+void terminate(char *, ...);
+void aborterr(char *, ...);
+void set_terminate_cleanup(void (*)());
void elfterminate(const char *, const 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);
+void warning(char *, ...);
+void vadebug(int, char *, va_list);
+void debug(int, char *, ...);
#ifdef __cplusplus
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
index 19aeff2..a7e97df 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
@@ -84,7 +84,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <strings.h>
#include <errno.h>
#include <libelf.h>
@@ -129,7 +128,7 @@
typedef struct dwarf {
Dwarf_Debug dw_dw; /* for libdwarf */
Dwarf_Error dw_err; /* for libdwarf */
- Dwarf_Off dw_maxoff; /* highest legal offset in this cu */
+ Dwarf_Unsigned dw_maxoff; /* highest legal offset in this cu */
tdata_t *dw_td; /* root of the tdesc/iidesc tree */
hash_t *dw_tidhash; /* hash of tdescs by t_id */
hash_t *dw_fwdhash; /* hash of fwd decls by name */
@@ -160,12 +159,11 @@ tdesc_add(dwarf_t *dw, tdesc_t *tdp)
static tdesc_t *
tdesc_lookup(dwarf_t *dw, int tid)
{
- tdesc_t tmpl;
- void *tdp;
+ tdesc_t tmpl, *tdp;
tmpl.t_id = tid;
- if (hash_find(dw->dw_tidhash, &tmpl, &tdp))
+ if (hash_find(dw->dw_tidhash, &tmpl, (void **)&tdp))
return (tdp);
else
return (NULL);
@@ -273,7 +271,7 @@ die_off(dwarf_t *dw, Dwarf_Die die)
return (off);
terminate("failed to get offset for die: %s\n",
- dwarf_errmsg(&dw->dw_err));
+ dwarf_errmsg(dw->dw_err));
/*NOTREACHED*/
return (0);
}
@@ -291,7 +289,7 @@ die_sibling(dwarf_t *dw, Dwarf_Die die)
return (NULL);
terminate("die %llu: failed to find type sibling: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+ die_off(dw, die), dwarf_errmsg(dw->dw_err));
/*NOTREACHED*/
return (NULL);
}
@@ -308,7 +306,7 @@ die_child(dwarf_t *dw, Dwarf_Die die)
return (NULL);
terminate("die %llu: failed to find type child: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+ die_off(dw, die), dwarf_errmsg(dw->dw_err));
/*NOTREACHED*/
return (NULL);
}
@@ -322,7 +320,7 @@ die_tag(dwarf_t *dw, Dwarf_Die die)
return (tag);
terminate("die %llu: failed to get tag for type: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+ die_off(dw, die), dwarf_errmsg(dw->dw_err));
/*NOTREACHED*/
return (0);
}
@@ -345,23 +343,43 @@ die_attr(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, int req)
}
terminate("die %llu: failed to get attribute for type: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+ die_off(dw, die), dwarf_errmsg(dw->dw_err));
/*NOTREACHED*/
return (NULL);
}
+static Dwarf_Half
+die_attr_form(dwarf_t *dw, Dwarf_Attribute attr)
+{
+ Dwarf_Half form;
+
+ if (dwarf_whatform(attr, &form, &dw->dw_err) == DW_DLV_OK)
+ return (form);
+
+ terminate("failed to get attribute form for type: %s\n",
+ dwarf_errmsg(dw->dw_err));
+ /*NOTREACHED*/
+ return (0);
+}
+
static int
die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp,
int req)
{
- *valp = 0;
- if (dwarf_attrval_signed(die, name, valp, &dw->dw_err) != DWARF_E_NONE) {
- if (req)
- terminate("die %llu: failed to get signed: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
- return (0);
+ Dwarf_Attribute attr;
+ Dwarf_Signed val;
+
+ if ((attr = die_attr(dw, die, name, req)) == NULL)
+ return (0); /* die_attr will terminate for us if necessary */
+
+ if (dwarf_formsdata(attr, &val, &dw->dw_err) != DW_DLV_OK) {
+ terminate("die %llu: failed to get signed (form 0x%x)\n",
+ die_off(dw, die), die_attr_form(dw, attr));
}
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
+
+ *valp = val;
return (1);
}
@@ -369,47 +387,59 @@ static int
die_unsigned(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Unsigned *valp,
int req)
{
- *valp = 0;
- if (dwarf_attrval_unsigned(die, name, valp, &dw->dw_err) != DWARF_E_NONE) {
- if (req)
- terminate("die %llu: failed to get unsigned: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
- return (0);
+ Dwarf_Attribute attr;
+ Dwarf_Unsigned val;
+
+ if ((attr = die_attr(dw, die, name, req)) == NULL)
+ return (0); /* die_attr will terminate for us if necessary */
+
+ if (dwarf_formudata(attr, &val, &dw->dw_err) != DW_DLV_OK) {
+ terminate("die %llu: failed to get unsigned (form 0x%x)\n",
+ die_off(dw, die), die_attr_form(dw, attr));
}
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
+
+ *valp = val;
return (1);
}
static int
die_bool(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Bool *valp, int req)
{
- *valp = 0;
+ Dwarf_Attribute attr;
+ Dwarf_Bool val;
+
+ if ((attr = die_attr(dw, die, name, req)) == NULL)
+ return (0); /* die_attr will terminate for us if necessary */
- if (dwarf_attrval_flag(die, name, valp, &dw->dw_err) != DWARF_E_NONE) {
- if (req)
- terminate("die %llu: failed to get flag: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
- return (0);
+ if (dwarf_formflag(attr, &val, &dw->dw_err) != DW_DLV_OK) {
+ terminate("die %llu: failed to get bool (form 0x%x)\n",
+ die_off(dw, die), die_attr_form(dw, attr));
}
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
+
+ *valp = val;
return (1);
}
static int
die_string(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, char **strp, int req)
{
- const char *str = NULL;
+ Dwarf_Attribute attr;
+ char *str;
- if (dwarf_attrval_string(die, name, &str, &dw->dw_err) != DWARF_E_NONE ||
- str == NULL) {
- if (req)
- terminate("die %llu: failed to get string: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
- else
- *strp = NULL;
- return (0);
- } else
- *strp = xstrdup(str);
+ if ((attr = die_attr(dw, die, name, req)) == NULL)
+ return (0); /* die_attr will terminate for us if necessary */
+
+ if (dwarf_formstring(attr, &str, &dw->dw_err) != DW_DLV_OK) {
+ terminate("die %llu: failed to get string (form 0x%x)\n",
+ die_off(dw, die), die_attr_form(dw, attr));
+ }
+
+ *strp = xstrdup(str);
+ dwarf_dealloc(dw->dw_dw, str, DW_DLA_STRING);
return (1);
}
@@ -417,13 +447,18 @@ die_string(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, char **strp, int req)
static Dwarf_Off
die_attr_ref(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name)
{
+ Dwarf_Attribute attr;
Dwarf_Off off;
- if (dwarf_attrval_unsigned(die, name, &off, &dw->dw_err) != DWARF_E_NONE) {
- terminate("die %llu: failed to get ref: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+ attr = die_attr(dw, die, name, DW_ATTR_REQ);
+
+ if (dwarf_formref(attr, &off, &dw->dw_err) != DW_DLV_OK) {
+ terminate("die %llu: failed to get ref (form 0x%x)\n",
+ die_off(dw, die), die_attr_form(dw, attr));
}
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
+
return (off);
}
@@ -487,13 +522,21 @@ die_lookup_pass1(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name)
static int
die_mem_offset(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name,
- Dwarf_Unsigned *valp, int req __unused)
+ Dwarf_Unsigned *valp, int req)
{
- Dwarf_Locdesc *loc = NULL;
- Dwarf_Signed locnum = 0;
+ Dwarf_Attribute attr;
+ Dwarf_Locdesc *loc;
+ Dwarf_Signed locnum;
+
+ if ((attr = die_attr(dw, die, name, req)) == NULL)
+ return (0); /* die_attr will terminate for us if necessary */
+
+ if (dwarf_loclist(attr, &loc, &locnum, &dw->dw_err) != DW_DLV_OK) {
+ terminate("die %llu: failed to get mem offset location list\n",
+ die_off(dw, die));
+ }
- if (dwarf_locdesc(die, name, &loc, &locnum, &dw->dw_err) != DW_DLV_OK)
- return (0);
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
if (locnum != 1 || loc->ld_s->lr_atom != DW_OP_plus_uconst) {
terminate("die %llu: cannot parse member offset\n",
@@ -502,10 +545,8 @@ die_mem_offset(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name,
*valp = loc->ld_s->lr_number;
- if (loc != NULL)
- if (dwarf_locdesc_free(loc, &dw->dw_err) != DW_DLV_OK)
- terminate("die %llu: cannot free location descriptor: %s\n",
- die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+ dwarf_dealloc(dw->dw_dw, loc->ld_s, DW_DLA_LOC_BLOCK);
+ dwarf_dealloc(dw->dw_dw, loc, DW_DLA_LOCDESC);
return (1);
}
@@ -599,7 +640,7 @@ tdesc_array_create(dwarf_t *dw, Dwarf_Die dim, tdesc_t *arrtdp,
{
Dwarf_Unsigned uval;
Dwarf_Signed sval;
- tdesc_t *ctdp = NULL;
+ tdesc_t *ctdp;
Dwarf_Die dim2;
ardef_t *ar;
@@ -662,7 +703,7 @@ die_array_create(dwarf_t *dw, Dwarf_Die arr, Dwarf_Off off, tdesc_t *tdp)
Dwarf_Unsigned uval;
Dwarf_Die dim;
- debug(3, "die %llu <%llx>: creating array\n", off, off);
+ debug(3, "die %llu: creating array\n", off);
if ((dim = die_child(dw, arr)) == NULL ||
die_tag(dw, dim) != DW_TAG_subrange_type)
@@ -693,13 +734,13 @@ die_array_create(dwarf_t *dw, Dwarf_Die arr, Dwarf_Off off, tdesc_t *tdp)
tdp->t_flags |= flags;
}
- debug(3, "die %llu <%llx>: array nelems %u size %u\n", off, off,
+ debug(3, "die %llu: array nelems %u size %u\n", off,
tdp->t_ardef->ad_nelems, tdp->t_size);
}
/*ARGSUSED1*/
static int
-die_array_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
+die_array_resolve(tdesc_t *tdp, tdesc_t **tdpp, void *private)
{
dwarf_t *dw = private;
size_t sz;
@@ -729,7 +770,7 @@ die_array_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
/*ARGSUSED1*/
static int
-die_array_failed(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private __unused)
+die_array_failed(tdesc_t *tdp, tdesc_t **tdpp, void *private)
{
tdesc_t *cont = tdp->t_ardef->ad_contents;
@@ -825,7 +866,7 @@ die_enum_match(void *arg1, void *arg2)
/*ARGSUSED1*/
static int
-die_enum_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
+die_enum_resolve(tdesc_t *tdp, tdesc_t **tdpp, void *private)
{
dwarf_t *dw = private;
tdesc_t *full = NULL;
@@ -897,9 +938,8 @@ die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp,
/*
* GCC allows empty SOUs as an extension.
*/
- if ((mem = die_child(dw, str)) == NULL) {
+ if ((mem = die_child(dw, str)) == NULL)
goto out;
- }
mlastp = &tdp->t_members;
@@ -926,7 +966,7 @@ die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp,
* bug 11816).
*/
if ((ml->ml_name = die_name(dw, mem)) == NULL)
- ml->ml_name = NULL;
+ ml->ml_name = "";
ml->ml_type = die_lookup_pass1(dw, mem, DW_AT_type);
@@ -943,7 +983,7 @@ die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp,
ml->ml_size = tdesc_bitsize(ml->ml_type);
if (die_unsigned(dw, mem, DW_AT_bit_offset, &bitoff, 0)) {
-#if BYTE_ORDER == _BIG_ENDIAN
+#ifdef _BIG_ENDIAN
ml->ml_offset += bitoff;
#else
ml->ml_offset += tdesc_bitsize(ml->ml_type) - bitoff -
@@ -1017,7 +1057,7 @@ die_union_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
/*ARGSUSED1*/
static int
-die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
+die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp, void *private)
{
dwarf_t *dw = private;
mlist_t *ml;
@@ -1076,7 +1116,7 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
/*ARGSUSED1*/
static int
-die_sou_failed(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private __unused)
+die_sou_failed(tdesc_t *tdp, tdesc_t **tdpp, void *private)
{
const char *typename = (tdp->t_type == STRUCT ? "struct" : "union");
mlist_t *ml;
@@ -1086,11 +1126,10 @@ die_sou_failed(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private __unused)
for (ml = tdp->t_members; ml != NULL; ml = ml->ml_next) {
if (ml->ml_size == 0) {
- fprintf(stderr, "%s %d <%x>: failed to size member \"%s\" "
- "of type %s (%d <%x>)\n", typename, tdp->t_id,
- tdp->t_id,
+ fprintf(stderr, "%s %d: failed to size member \"%s\" "
+ "of type %s (%d)\n", typename, tdp->t_id,
ml->ml_name, tdesc_name(ml->ml_type),
- ml->ml_type->t_id, ml->ml_type->t_id);
+ ml->ml_type->t_id);
}
}
@@ -1106,7 +1145,7 @@ die_funcptr_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
fndef_t *fn;
int i;
- debug(3, "die %llu <%llx>: creating function pointer\n", off, off);
+ debug(3, "die %llu: creating function pointer\n", off);
/*
* We'll begin by processing any type definition nodes that may be
@@ -1136,6 +1175,7 @@ die_funcptr_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
tdp->t_type = FUNCTION;
if ((attr = die_attr(dw, die, DW_AT_type, 0)) != NULL) {
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
fn->fn_ret = die_lookup_pass1(dw, die, DW_AT_type);
} else {
fn->fn_ret = tdesc_intr_void(dw);
@@ -1159,7 +1199,7 @@ die_funcptr_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
fn->fn_args = xcalloc(sizeof (tdesc_t *) * fn->fn_nargs);
for (i = 0, arg = die_child(dw, die);
- arg != NULL && i < (int) fn->fn_nargs;
+ arg != NULL && i < fn->fn_nargs;
arg = die_sibling(dw, arg)) {
if (die_tag(dw, arg) != DW_TAG_formal_parameter)
continue;
@@ -1184,8 +1224,7 @@ static intr_t *
die_base_name_parse(const char *name, char **newp)
{
char buf[100];
- char const *base;
- char *c;
+ char *base, *c;
int nlong = 0, nshort = 0, nchar = 0, nint = 0;
int sign = 1;
char fmt = '\0';
@@ -1269,7 +1308,7 @@ static const fp_size_map_t fp_encodings[] = {
#else
{ { 12, 16 }, { CTF_FP_LDOUBLE, CTF_FP_LDCPLX, CTF_FP_LDIMAGRY } },
#endif
- { { 0, 0 }, { 0, 0, 0 } }
+ { { 0, 0 } }
};
static uint_t
@@ -1282,11 +1321,8 @@ die_base_type2enc(dwarf_t *dw, Dwarf_Off off, Dwarf_Signed enc, size_t sz)
if (enc == DW_ATE_complex_float) {
mult = 2;
col = 1;
- } else if (enc == DW_ATE_imaginary_float
-#if defined(sun)
- || enc == DW_ATE_SUN_imaginary_float
-#endif
- )
+ } else if (enc == DW_ATE_imaginary_float ||
+ enc == DW_ATE_SUN_imaginary_float)
col = 2;
while (map->fsm_typesz[szidx] != 0) {
@@ -1334,10 +1370,8 @@ die_base_from_dwarf(dwarf_t *dw, Dwarf_Die base, Dwarf_Off off, size_t sz)
case DW_ATE_float:
case DW_ATE_complex_float:
case DW_ATE_imaginary_float:
-#if defined(sun)
case DW_ATE_SUN_imaginary_float:
case DW_ATE_SUN_interval_float:
-#endif
intr->intr_type = INTR_REAL;
intr->intr_signed = 1;
intr->intr_fformat = die_base_type2enc(dw, off, enc, sz);
@@ -1407,11 +1441,12 @@ die_through_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp,
{
Dwarf_Attribute attr;
- debug(3, "die %llu <%llx>: creating %s type %d\n", off, off, typename, type);
+ debug(3, "die %llu: creating %s\n", off, typename);
tdp->t_type = type;
if ((attr = die_attr(dw, die, DW_AT_type, 0)) != NULL) {
+ dwarf_dealloc(dw->dw_dw, attr, DW_DLA_ATTR);
tdp->t_tdesc = die_lookup_pass1(dw, die, DW_AT_type);
} else {
tdp->t_tdesc = tdesc_intr_void(dw);
@@ -1464,14 +1499,14 @@ die_volatile_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
/*ARGSUSED3*/
static void
-die_function_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp __unused)
+die_function_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
{
Dwarf_Die arg;
Dwarf_Half tag;
iidesc_t *ii;
char *name;
- debug(3, "die %llu <%llx>: creating function definition\n", off, off);
+ debug(3, "die %llu: creating function definition\n", off);
/*
* We'll begin by processing any type definition nodes that may be
@@ -1510,7 +1545,7 @@ die_function_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp __un
for (arg = die_child(dw, die); arg != NULL;
arg = die_sibling(dw, arg)) {
- char *name1;
+ char *name;
debug(3, "die %llu: looking at sub member at %llu\n",
off, die_off(dw, die));
@@ -1518,13 +1553,13 @@ die_function_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp __un
if (die_tag(dw, arg) != DW_TAG_formal_parameter)
continue;
- if ((name1 = die_name(dw, arg)) == NULL) {
+ if ((name = die_name(dw, arg)) == NULL) {
terminate("die %llu: func arg %d has no name\n",
off, ii->ii_nargs + 1);
}
- if (strcmp(name1, "...") == 0) {
- free(name1);
+ if (strcmp(name, "...") == 0) {
+ free(name);
ii->ii_vargs = 1;
continue;
}
@@ -1556,7 +1591,7 @@ die_function_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp __un
/*ARGSUSED3*/
static void
-die_variable_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp __unused)
+die_variable_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
{
iidesc_t *ii;
char *name;
@@ -1578,7 +1613,7 @@ die_variable_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp __un
/*ARGSUSED2*/
static int
-die_fwd_resolve(tdesc_t *fwd, tdesc_t **fwdp, void *private __unused)
+die_fwd_resolve(tdesc_t *fwd, tdesc_t **fwdp, void *private)
{
if (fwd->t_flags & TDESC_F_RESOLVED)
return (1);
@@ -1596,7 +1631,7 @@ die_fwd_resolve(tdesc_t *fwd, tdesc_t **fwdp, void *private __unused)
/*ARGSUSED*/
static void
-die_lexblk_descend(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off __unused, tdesc_t *tdp __unused)
+die_lexblk_descend(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
{
Dwarf_Die child = die_child(dw, die);
@@ -1634,7 +1669,7 @@ static const die_creator_t die_creators[] = {
{ DW_TAG_variable, DW_F_NOTDP, die_variable_create },
{ DW_TAG_volatile_type, 0, die_volatile_create },
{ DW_TAG_restrict_type, 0, die_restrict_create },
- { 0, 0, NULL }
+ { 0, NULL }
};
static const die_creator_t *
@@ -1658,7 +1693,7 @@ die_create_one(dwarf_t *dw, Dwarf_Die die)
Dwarf_Half tag;
tdesc_t *tdp;
- debug(3, "die %llu <%llx>: create_one\n", off, off);
+ debug(3, "die %llu: create_one\n", off);
if (off > dw->dw_maxoff) {
terminate("illegal die offset %llu (max %llu)\n", off,
@@ -1742,7 +1777,7 @@ die_resolve(dwarf_t *dw)
debug(3, "resolve: pass %d, %u left\n", pass, dw->dw_nunres);
- if ((int) dw->dw_nunres == last) {
+ if (dw->dw_nunres == last) {
fprintf(stderr, "%s: failed to resolve the following "
"types:\n", progname);
@@ -1760,12 +1795,11 @@ die_resolve(dwarf_t *dw)
/*ARGSUSED*/
int
-dw_read(tdata_t *td, Elf *elf, char *filename __unused)
+dw_read(tdata_t *td, Elf *elf, const char *filename)
{
Dwarf_Unsigned abboff, hdrlen, nxthdr;
Dwarf_Half vers, addrsz;
- Dwarf_Die cu = 0;
- Dwarf_Die child = 0;
+ Dwarf_Die cu, child;
dwarf_t dw;
char *prod = NULL;
int rc;
@@ -1780,12 +1814,12 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused)
dw.dw_enumhash = hash_new(TDESC_HASH_BUCKETS, tdesc_namehash,
tdesc_namecmp);
- if ((rc = dwarf_elf_init(elf, DW_DLC_READ, &dw.dw_dw,
+ if ((rc = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dw.dw_dw,
&dw.dw_err)) == DW_DLV_NO_ENTRY) {
errno = ENOENT;
return (-1);
} else if (rc != DW_DLV_OK) {
- if (dwarf_errno(&dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) {
+ if (dwarf_errno(dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) {
/*
* There's no type data in the DWARF section, but
* libdwarf is too clever to handle that properly.
@@ -1794,14 +1828,13 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused)
}
terminate("failed to initialize DWARF: %s\n",
- dwarf_errmsg(&dw.dw_err));
+ dwarf_errmsg(dw.dw_err));
}
if ((rc = dwarf_next_cu_header(dw.dw_dw, &hdrlen, &vers, &abboff,
- &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK)
- terminate("rc = %d %s\n", rc, dwarf_errmsg(&dw.dw_err));
-
- if ((cu = die_sibling(&dw, NULL)) == NULL)
+ &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK ||
+ (cu = die_sibling(&dw, NULL)) == NULL ||
+ (child = die_child(&dw, cu)) == NULL)
terminate("file does not contain dwarf type data "
"(try compiling with -g)\n");
@@ -1829,14 +1862,13 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused)
debug(1, "CU name: %s\n", dw.dw_cuname);
}
- if ((child = die_child(&dw, cu)) != NULL)
- die_create(&dw, child);
+ die_create(&dw, child);
if ((rc = dwarf_next_cu_header(dw.dw_dw, &hdrlen, &vers, &abboff,
&addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_NO_ENTRY)
terminate("multiple compilation units not supported\n");
- (void) dwarf_finish(&dw.dw_dw, &dw.dw_err);
+ (void) dwarf_finish(dw.dw_dw, &dw.dw_err);
die_resolve(&dw);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c b/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
index b239a62..8524693 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
@@ -52,17 +52,17 @@
static void
fix_ptrptr_to_struct(tdata_t *td)
{
- 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" };
+ char *strs[2] = { "as", "fdbuffer" };
+ char *mems[2] = { "a_objectdir", "fd_shadow" };
+ char *acts[2] = { "vnode", "page" };
+ 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 < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
+ for (i = 0; i < sizeof (strs) / sizeof (strs[0]); i++) {
if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
continue;
@@ -106,8 +106,8 @@ fix_ptrptr_to_struct(tdata_t *td)
static void
fix_ptr_to_struct(tdata_t *td)
{
- const char *strs[2] = { "vmem", "id_space" };
- const char *mems[2] = { NULL, "is_vmem" };
+ char *strs[2] = { "vmem", "id_space" };
+ char *mems[2] = { NULL, "is_vmem" };
tdesc_t *ptr = NULL;
tdesc_t *str, *vmt;
mlist_t *ml;
@@ -116,7 +116,7 @@ fix_ptr_to_struct(tdata_t *td)
if ((vmt = lookupname("vmem_t")) == NULL || vmt->t_type != TYPEDEF)
return;
- for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
+ for (i = 0; i < sizeof (strs) / sizeof (strs[0]); i++) {
if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
continue;
@@ -163,10 +163,8 @@ struct match {
};
static int
-matching_iidesc(void *arg1, void *arg2)
+matching_iidesc(iidesc_t *iidesc, struct match *match)
{
- iidesc_t *iidesc = arg1;
- struct match *match = arg2;
if (!streq(iidesc->ii_name, match->m_name))
return (0);
@@ -178,10 +176,10 @@ matching_iidesc(void *arg1, void *arg2)
}
static tdesc_t *
-lookup_tdesc(tdata_t *td, char const *name)
+lookup_tdesc(tdata_t *td, const char *name)
{
struct match match = { NULL, name };
- iter_iidescs_by_name(td, name, matching_iidesc, &match);
+ iter_iidescs_by_name(td, name, (int (*)())matching_iidesc, &match);
return (match.m_ret);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c b/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
index 36ed45a..e3c2978 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
@@ -50,7 +50,7 @@ struct hash {
struct hash_data {
hash_t *hd_hash;
- int (*hd_fun)(void *, void *);
+ int (*hd_fun)();
void *hd_key;
void *hd_private;
@@ -58,14 +58,13 @@ struct hash_data {
};
static int
-hash_def_hash(int nbuckets, void *arg)
+hash_def_hash(int nbuckets, uintptr_t data)
{
- uintptr_t data = (uintptr_t) arg;
return (data % nbuckets);
}
static int
-hash_def_cmp(void *d1, void *d2)
+hash_def_cmp(uintptr_t d1, uintptr_t d2)
{
return (d1 != d2);
}
@@ -97,8 +96,8 @@ hash_new(int nbuckets, int (*hashfn)(int, void *), int (*cmp)(void *, void *))
hash = xmalloc(sizeof (hash_t));
hash->h_buckets = xcalloc(sizeof (list_t *) * nbuckets);
hash->h_nbuckets = nbuckets;
- hash->h_hashfn = hashfn ? hashfn : hash_def_hash;
- hash->h_cmp = cmp ? cmp : hash_def_cmp;
+ hash->h_hashfn = hashfn ? hashfn : (int (*)())hash_def_hash;
+ hash->h_cmp = cmp ? cmp : (int (*)())hash_def_cmp;
return (hash);
}
@@ -125,9 +124,8 @@ hash_merge(hash_t *to, hash_t *from)
}
static int
-hash_remove_cb(void *key1, void *key2, void *arg)
+hash_remove_cb(void *key1, void *key2, hash_t *hash)
{
- hash_t *hash = arg;
return (hash->h_cmp(key1, key2));
}
@@ -137,7 +135,7 @@ hash_remove(hash_t *hash, void *key)
int bucket = hash->h_hashfn(hash->h_nbuckets, key);
(void) list_remove(&hash->h_buckets[bucket], key,
- hash_remove_cb, hash);
+ (int (*)())hash_remove_cb, hash);
}
int
@@ -150,9 +148,8 @@ hash_match(hash_t *hash, void *key, int (*fun)(void *, void *),
}
static int
-hash_find_list_cb(void *node, void *arg)
+hash_find_list_cb(void *node, struct hash_data *hd)
{
- struct hash_data *hd = arg;
int cbrc;
int rc = 0;
@@ -177,15 +174,14 @@ hash_find_iter(hash_t *hash, void *key, int (*fun)(void *, void *),
hd.hd_key = key;
hd.hd_private = private;
- return (list_iter(hash->h_buckets[bucket], hash_find_list_cb,
+ return (list_iter(hash->h_buckets[bucket], (int (*)())hash_find_list_cb,
&hd));
}
/* stop on first match */
static int
-hash_find_first_cb(void *node, void *arg)
+hash_find_first_cb(void *node, struct hash_data *hd)
{
- struct hash_data *hd = arg;
if (hd->hd_hash->h_cmp(hd->hd_key, node) == 0) {
hd->hd_ret = node;
return (-1);
@@ -204,7 +200,7 @@ hash_find(hash_t *hash, void *key, void **value)
hd.hd_fun = hash_find_first_cb;
hd.hd_key = key;
- ret = hash_match(hash, key, hash_find_first_cb, &hd);
+ ret = hash_match(hash, key, (int (*)())hash_find_first_cb, &hd);
if (ret && value)
*value = hd.hd_ret;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c b/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
index fc1cefc..b6b9a0c 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
@@ -68,10 +68,8 @@ iidesc_hash(int nbuckets, void *arg)
}
static int
-iidesc_cmp(void *arg1, void *arg2)
+iidesc_cmp(iidesc_t *src, iidesc_find_t *find)
{
- iidesc_t *src = arg1;
- iidesc_find_t *find = arg2;
iidesc_t *tgt = find->iif_tgt;
if (src->ii_type != tgt->ii_type ||
@@ -91,7 +89,7 @@ iidesc_add(hash_t *hash, iidesc_t *new)
find.iif_tgt = new;
find.iif_ret = NULL;
- (void) hash_match(hash, new, iidesc_cmp, &find);
+ (void) hash_match(hash, new, (int (*)())iidesc_cmp, &find);
if (find.iif_ret != NULL) {
iidesc_t *old = find.iif_ret;
@@ -109,14 +107,13 @@ iidesc_add(hash_t *hash, iidesc_t *new)
}
void
-iter_iidescs_by_name(tdata_t *td, char const *name,
- int (*func)(void *, void *), void *data)
+iter_iidescs_by_name(tdata_t *td, const char *name,
+ int (*func)(iidesc_t *, void *), void *data)
{
iidesc_t tmpdesc;
- bzero(&tmpdesc, sizeof(tmpdesc));
- tmpdesc.ii_name = xstrdup(name);
- (void) hash_match(td->td_iihash, &tmpdesc, func, data);
- free(tmpdesc.ii_name);
+ bzero(&tmpdesc, sizeof (iidesc_t));
+ tmpdesc.ii_name = (char *)name;
+ (void) hash_match(td->td_iihash, &tmpdesc, (int (*)())func, data);
}
iidesc_t *
@@ -154,9 +151,8 @@ iidesc_dup_rename(iidesc_t *src, char const *name, char const *owner)
/*ARGSUSED*/
void
-iidesc_free(void *arg, void *private __unused)
+iidesc_free(iidesc_t *idp, void *private)
{
- iidesc_t *idp = arg;
if (idp->ii_name)
free(idp->ii_name);
if (idp->ii_nargs)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/input.c b/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
index 67ebde7..d901e53 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
@@ -71,7 +71,6 @@ built_source_types(Elf *elf, char const *file)
/* ignore */
break;
case 's':
- case 'S':
types |= SOURCE_S;
break;
default:
@@ -88,7 +87,7 @@ read_file(Elf *elf, char *file, char *label, read_cb_f *func, void *arg,
int require_ctf)
{
Elf_Scn *ctfscn;
- Elf_Data *ctfdata = NULL;
+ Elf_Data *ctfdata;
symit_data_t *si = NULL;
int ctfscnidx;
tdata_t *td;
@@ -221,7 +220,7 @@ read_ctf_common(char *file, char *label, read_cb_f *func, void *arg,
/*ARGSUSED*/
int
-read_ctf_save_cb(tdata_t *td, char *name __unused, void *retp)
+read_ctf_save_cb(tdata_t *td, char *name, void *retp)
{
tdata_t **tdp = retp;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
index 2ef37d4..2af28b6 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
@@ -132,7 +132,7 @@ typedef struct merge_cb_data merge_cb_data_t;
* own traversal mechanism and ops vector here for those two cases.
*/
typedef struct tdesc_ops {
- const char *name;
+ 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,21 +179,21 @@ struct merge_cb_data {
static void
add_mapping(alist_t *ta, tid_t srcid, tid_t tgtid)
{
- debug(3, "Adding mapping %u <%x> => %u <%x>\n", srcid, srcid, tgtid, tgtid);
+ debug(3, "Adding mapping %u => %u\n", srcid, tgtid);
- assert(!alist_find(ta, (void *)(uintptr_t)srcid, NULL));
+ assert(!alist_find(ta, (void *)srcid, NULL));
assert(srcid != 0 && tgtid != 0);
- alist_add(ta, (void *)(uintptr_t)srcid, (void *)(uintptr_t)tgtid);
+ alist_add(ta, (void *)srcid, (void *)tgtid);
}
static tid_t
get_mapping(alist_t *ta, int srcid)
{
- void *ltgtid;
+ long ltgtid;
- if (alist_find(ta, (void *)(uintptr_t)srcid, (void **)&ltgtid))
- return ((uintptr_t)ltgtid);
+ if (alist_find(ta, (void *)srcid, (void **)&ltgtid))
+ return ((int)ltgtid);
else
return (0);
}
@@ -216,7 +216,7 @@ static int equiv_node(tdesc_t *, tdesc_t *, equiv_data_t *);
/*ARGSUSED2*/
static int
-equiv_intrinsic(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
+equiv_intrinsic(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
{
intr_t *si = stdp->t_intr;
intr_t *ti = ttdp->t_intr;
@@ -256,7 +256,7 @@ equiv_function(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
if (!equiv_node(fn1->fn_ret, fn2->fn_ret, ed))
return (0);
- for (i = 0; i < (int) fn1->fn_nargs; i++) {
+ for (i = 0; i < fn1->fn_nargs; i++) {
if (!equiv_node(fn1->fn_args[i], fn2->fn_args[i], ed))
return (0);
}
@@ -313,7 +313,7 @@ equiv_su(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
/*ARGSUSED2*/
static int
-equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
+equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
{
elist_t *el1 = stdp->t_emem;
elist_t *el2 = ttdp->t_emem;
@@ -335,7 +335,7 @@ equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
/*ARGSUSED*/
static int
-equiv_assert(tdesc_t *stdp __unused, tdesc_t *ttdp __unused, equiv_data_t *ed __unused)
+equiv_assert(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
{
/* foul, evil, and very bad - this is a "shouldn't happen" */
assert(1 == 0);
@@ -354,7 +354,7 @@ fwd_equiv(tdesc_t *ctdp, tdesc_t *mtdp)
static int
equiv_node(tdesc_t *ctdp, tdesc_t *mtdp, equiv_data_t *ed)
{
- int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
+ int (*equiv)();
int mapping;
if (ctdp->t_emark > ed->ed_clear_mark ||
@@ -418,8 +418,7 @@ equiv_cb(void *bucket, void *arg)
ed->ed_cur_mark = ed->ed_clear_mark + 1;
if (equiv_node(ctdp, mtdp, ed)) {
- debug(3, "equiv_node matched %d <%x> %d <%x>\n",
- ctdp->t_id, ctdp->t_id, mtdp->t_id, mtdp->t_id);
+ debug(3, "equiv_node matched %d %d\n", ctdp->t_id, mtdp->t_id);
ed->ed_tgt = mtdp;
/* matched. stop looking */
return (-1);
@@ -430,7 +429,7 @@ equiv_cb(void *bucket, void *arg)
/*ARGSUSED1*/
static int
-map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
+map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
{
merge_cb_data_t *mcd = private;
@@ -442,7 +441,7 @@ map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
/*ARGSUSED1*/
static int
-map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
+map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
{
merge_cb_data_t *mcd = private;
equiv_data_t ed;
@@ -453,7 +452,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
ed.ed_node = ctdp;
ed.ed_selfuniquify = 0;
- debug(3, "map_td_tree_post on %d <%x> %s\n", ctdp->t_id, ctdp->t_id,tdesc_name(ctdp));
+ debug(3, "map_td_tree_post on %d %s\n", ctdp->t_id, tdesc_name(ctdp));
if (hash_find_iter(mcd->md_parent->td_layouthash, ctdp,
equiv_cb, &ed) < 0) {
@@ -461,7 +460,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
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 <%x>\n", id, id);
+ debug(3, "Creating new defn type %d\n", 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);
@@ -482,7 +481,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
} else {
int id = mcd->md_tgt->td_nextid++;
- debug(3, "Creating new type %d <%x>\n", id, id);
+ debug(3, "Creating new type %d\n", id);
add_mapping(mcd->md_ta, ctdp->t_id, id);
hash_add(mcd->md_tdtba, ctdp);
}
@@ -494,7 +493,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
/*ARGSUSED1*/
static int
-map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
+map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
{
merge_cb_data_t *mcd = private;
equiv_data_t ed;
@@ -507,8 +506,8 @@ map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
ed.ed_tgt = NULL;
if (hash_find_iter(mcd->md_tdtba, ctdp, equiv_cb, &ed) < 0) {
- 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);
+ debug(3, "Self check found %d in %d\n", ctdp->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,
@@ -519,13 +518,12 @@ map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
* through the entire hash. This usually means that the hash
* function is broken.
*/
- 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);
+ aborterr("Self-unique second pass for %d (%s) == %d\n",
+ ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id);
} else {
int id = mcd->md_tgt->td_nextid++;
- debug(3, "Creating new type %d <%x>\n", id, id);
+ debug(3, "Creating new type %d\n", id);
add_mapping(mcd->md_ta, ctdp->t_id, id);
hash_add(mcd->md_tdtba, ctdp);
}
@@ -698,14 +696,14 @@ remap_node(tdesc_t **tgtp, tdesc_t *oldtgt, int selftid, tdesc_t *newself,
}
if ((template.t_id = get_mapping(mcd->md_ta, oldid)) == 0)
- aborterr("failed to get mapping for tid %d <%x>\n", oldid, oldid);
+ aborterr("failed to get mapping for tid %d\n", 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 <%x> (from %d <%x>)\n", template.t_id,
- template.t_id, oldid, oldid);
+ debug(3, "Remap couldn't find %d (from %d)\n", template.t_id,
+ oldid);
*tgtp = oldtgt;
list_add(mcd->md_tdtbr, tgtp);
return (0);
@@ -731,7 +729,7 @@ conjure_template(tdesc_t *old, int newselfid)
/*ARGSUSED2*/
static tdesc_t *
-conjure_intrinsic(tdesc_t *old, int newselfid, merge_cb_data_t *mcd __unused)
+conjure_intrinsic(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
{
tdesc_t *new = conjure_template(old, newselfid);
@@ -767,7 +765,7 @@ conjure_function(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
if (nfn->fn_nargs > 0)
nfn->fn_args = xcalloc(sizeof (tdesc_t *) * ofn->fn_nargs);
- for (i = 0; i < (int) ofn->fn_nargs; i++) {
+ for (i = 0; i < ofn->fn_nargs; i++) {
(void) remap_node(&nfn->fn_args[i], ofn->fn_args[i], old->t_id,
new, mcd);
}
@@ -807,7 +805,7 @@ conjure_su(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
*nmemp = xmalloc(sizeof (mlist_t));
(*nmemp)->ml_offset = omem->ml_offset;
(*nmemp)->ml_size = omem->ml_size;
- (*nmemp)->ml_name = xstrdup(omem->ml_name ? omem->ml_name : "empty omem->ml_name");
+ (*nmemp)->ml_name = xstrdup(omem->ml_name);
(void) remap_node(&((*nmemp)->ml_type), omem->ml_type,
old->t_id, new, mcd);
}
@@ -818,7 +816,7 @@ conjure_su(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
/*ARGSUSED2*/
static tdesc_t *
-conjure_enum(tdesc_t *old, int newselfid, merge_cb_data_t *mcd __unused)
+conjure_enum(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
{
tdesc_t *new = conjure_template(old, newselfid);
elist_t *oel, **nelp;
@@ -847,7 +845,7 @@ conjure_forward(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
/*ARGSUSED*/
static tdesc_t *
-conjure_assert(tdesc_t *old __unused, int newselfid __unused, merge_cb_data_t *mcd __unused)
+conjure_assert(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
{
assert(1 == 0);
return (NULL);
@@ -872,7 +870,7 @@ static int
fwd_redir(tdesc_t *fwd, tdesc_t **fwdp, void *private)
{
alist_t *map = private;
- void *defn;
+ tdesc_t *defn;
if (!alist_find(map, (void *)fwd, (void **)&defn))
return (0);
@@ -910,7 +908,7 @@ static int
redir_mstr_fwd_cb(void *name, void *value, void *arg)
{
tdesc_t *fwd = name;
- int defnid = (uintptr_t)value;
+ int defnid = (int)value;
redir_mstr_data_t *rmd = arg;
tdesc_t template;
tdesc_t *defn;
@@ -989,9 +987,8 @@ add_tdesc(tdesc_t *oldtdp, int newid, merge_cb_data_t *mcd)
assert(hash_find(mcd->md_parent->td_idhash,
(void *)&template, NULL) == 0);
- 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);
+ debug(3, "trying to conjure %d %s (%d) as %d\n",
+ oldtdp->t_type, tdesc_name(oldtdp), oldtdp->t_id, newid);
if ((newtdp = tdesc_ops[oldtdp->t_type].conjure(oldtdp, newid,
mcd)) == NULL)
@@ -1052,16 +1049,16 @@ merge_types(hash_t *src, merge_cb_data_t *mcd)
(void) hash_iter(src, merge_type_cb, mcd);
- tdrc = hash_iter(mcd->md_tdtba, add_tdtba_cb, mcd);
+ tdrc = hash_iter(mcd->md_tdtba, add_tdtba_cb, (void *)mcd);
debug(3, "add_tdtba_cb added %d items\n", tdrc);
- iirc = list_iter(*mcd->md_iitba, add_iitba_cb, mcd);
+ iirc = list_iter(*mcd->md_iitba, add_iitba_cb, (void *)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, mcd);
+ tdrc = list_iter(*mcd->md_tdtbr, add_tdtbr_cb, (void *)mcd);
debug(3, "add_tdtbr_cb added %d items\n", tdrc);
if (list_count(*mcd->md_tdtbr) != 0)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
index ae8c594..f699fbf 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
@@ -79,7 +79,7 @@ burst_iitypes(void *data, void *arg)
/*ARGSUSED1*/
static int
-save_type_by_id(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
+save_type_by_id(tdesc_t *tdp, tdesc_t **tdpp, void *private)
{
iiburst_t *iiburst = private;
@@ -159,10 +159,8 @@ iiburst_free(iiburst_t *iiburst)
* a global type description.
*/
static int
-matching_iidesc(void *arg1, void *arg2)
+matching_iidesc(iidesc_t *iidesc, iidesc_match_t *match)
{
- iidesc_t *iidesc = arg1;
- iidesc_match_t *match = arg2;
if (streq(iidesc->ii_name, match->iim_name) == 0)
return (0);
@@ -187,8 +185,6 @@ matching_iidesc(void *arg1, void *arg2)
return (-1);
}
break;
- default:
- break;
}
return (0);
}
@@ -198,7 +194,7 @@ find_iidesc(tdata_t *td, iidesc_match_t *match)
{
match->iim_ret = NULL;
iter_iidescs_by_name(td, match->iim_name,
- matching_iidesc, match);
+ (int (*)())matching_iidesc, match);
return (match->iim_ret);
}
@@ -243,12 +239,10 @@ check_for_weak(GElf_Sym *weak, char const *weakfile,
GElf_Sym *retsym, char **curfilep)
{
char *curfile = NULL;
- char *tmpfile1 = NULL;
+ char *tmpfile;
GElf_Sym tmpsym;
int candidate = 0;
int i;
- tmpsym.st_info = 0;
- tmpsym.st_name = 0;
if (GELF_ST_BIND(weak->st_info) != STB_WEAK)
return (0);
@@ -282,7 +276,7 @@ check_for_weak(GElf_Sym *weak, char const *weakfile,
(curfile == NULL || weakfile == NULL ||
strcmp(curfile, weakfile) != 0)) {
candidate = 1;
- tmpfile1 = curfile;
+ tmpfile = curfile;
tmpsym = sym;
continue;
}
@@ -293,7 +287,7 @@ check_for_weak(GElf_Sym *weak, char const *weakfile,
}
if (candidate) {
- *curfilep = tmpfile1;
+ *curfilep = tmpfile;
*retsym = tmpsym;
return (1);
}
@@ -502,14 +496,14 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
secxlate = xmalloc(sizeof (int) * sehdr.e_shnum);
for (srcidx = dstidx = 0; srcidx < sehdr.e_shnum; srcidx++) {
Elf_Scn *scn = elf_getscn(src, srcidx);
- GElf_Shdr shdr1;
+ GElf_Shdr shdr;
char *sname;
- gelf_getshdr(scn, &shdr1);
- sname = elf_strptr(src, sehdr.e_shstrndx, shdr1.sh_name);
+ gelf_getshdr(scn, &shdr);
+ sname = elf_strptr(src, sehdr.e_shstrndx, shdr.sh_name);
if (sname == NULL) {
elfterminate(srcname, "Can't find string at %u",
- shdr1.sh_name);
+ shdr.sh_name);
}
if (strcmp(sname, CTF_ELF_SCN_NAME) == 0) {
@@ -520,7 +514,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
strncmp(sname, ".rel.debug", 10) == 0 ||
strncmp(sname, ".rela.debug", 11) == 0)) {
secxlate[srcidx] = -1;
- } else if (dynsym && shdr1.sh_type == SHT_SYMTAB) {
+ } else if (dynsym && shdr.sh_type == SHT_SYMTAB) {
/*
* If we're building CTF against the dynsym,
* we'll rip out the symtab so debuggers aren't
@@ -573,31 +567,11 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
elfterminate(srcname, "Can't find string at %u",
shdr.sh_name);
}
-
-#if !defined(sun)
- if (gelf_update_shdr(dscn, &shdr) == 0)
- elfterminate(dstname, "Cannot update sect %s", sname);
-#endif
-
if ((sdata = elf_getdata(sscn, NULL)) == NULL)
elfterminate(srcname, "Cannot get sect %s data", sname);
if ((ddata = elf_newdata(dscn)) == NULL)
elfterminate(dstname, "Can't make sect %s data", sname);
-#if defined(sun)
bcopy(sdata, ddata, sizeof (Elf_Data));
-#else
- /*
- * FreeBSD's Elf_Data has private fields which the
- * elf_* routines manage. Simply copying the
- * entire structure corrupts the data. So we need
- * to copy the public fields explictly.
- */
- ddata->d_align = sdata->d_align;
- ddata->d_off = sdata->d_off;
- ddata->d_size = sdata->d_size;
- ddata->d_type = sdata->d_type;
- ddata->d_version = sdata->d_version;
-#endif
if (srcidx == sehdr.e_shstrndx) {
char seclen = strlen(CTF_ELF_SCN_NAME);
@@ -627,8 +601,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
GElf_Sym sym;
short newscn;
- if (gelf_getsym(ddata, i, &sym) == NULL)
- printf("Could not get symbol %d\n",i);
+ (void) gelf_getsym(ddata, i, &sym);
if (sym.st_shndx >= SHN_LORESERVE)
continue;
@@ -643,14 +616,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
}
}
-#if !defined(sun)
- if (ddata->d_buf == NULL) {
- ddata->d_buf = xmalloc(shdr.sh_size);
- bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size);
- }
-#endif
-
- if (gelf_update_shdr(dscn, &shdr) == 0)
+ if (gelf_update_shdr(dscn, &shdr) == NULL)
elfterminate(dstname, "Cannot update sect %s", sname);
new_offset = (off_t)shdr.sh_offset;
@@ -685,7 +651,6 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
ddata->d_buf = ctfdata;
ddata->d_size = ctfsize;
ddata->d_align = shdr.sh_addralign;
- ddata->d_off = 0;
gelf_update_shdr(dscn, &shdr);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
index 5364320..d4d4921 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
@@ -76,11 +76,12 @@ static char *tdefdecl(char *cp, int h, tdesc_t **rtdp);
static char *intrinsic(char *cp, tdesc_t **rtdp);
static char *arraydef(char *cp, tdesc_t **rtdp);
+extern int debug_level;
int debug_parse = DEBUG_PARSE;
/*PRINTFLIKE3*/
static void
-parse_debug(int level, char *cp, const char *fmt, ...)
+parse_debug(int level, char *cp, char *fmt, ...)
{
va_list ap;
char buf[1024];
@@ -112,9 +113,9 @@ parse_debug(int level, char *cp, const char *fmt, ...)
/* Report unexpected syntax in stabs. */
static void
_expected(
- const char *who, /* what function, or part thereof, is reporting */
- const char *what, /* what was expected */
- const char *where, /* where we were in the line of input */
+ char *who, /* what function, or part thereof, is reporting */
+ char *what, /* what was expected */
+ char *where, /* where we were in the line of input */
int line)
{
fprintf(stderr, "%s, expecting \"%s\" at \"%s\"\n", who, what, where);
@@ -125,7 +126,7 @@ _expected(
/*ARGSUSED*/
void
-parse_init(tdata_t *td __unused)
+parse_init(tdata_t *td)
{
int i;
@@ -158,7 +159,7 @@ unres_new(int tid)
return (tdp);
}
-static char *
+char *
read_tid(char *cp, tdesc_t **tdpp)
{
tdesc_t *tdp;
@@ -189,7 +190,7 @@ read_tid(char *cp, tdesc_t **tdpp)
static iitype_t
parse_fun(char *cp, iidesc_t *ii)
{
- iitype_t iitype = 0;
+ iitype_t iitype;
tdesc_t *tdp;
tdesc_t **args = NULL;
int nargs = 0;
@@ -249,7 +250,7 @@ static iitype_t
parse_sym(char *cp, iidesc_t *ii)
{
tdesc_t *tdp;
- iitype_t iitype = 0;
+ iitype_t iitype;
/*
* name:G global variable
@@ -1037,14 +1038,14 @@ enumdef(char *cp, tdesc_t **rtdp)
}
}
-static tdesc_t *
-lookup_name(tdesc_t **hash, const char *name1)
+tdesc_t *
+lookup_name(tdesc_t **hash, const char *name)
{
- int bucket = compute_sum(name1);
+ int bucket = compute_sum(name);
tdesc_t *tdp, *ttdp = NULL;
for (tdp = hash[bucket]; tdp != NULL; tdp = tdp->t_next) {
- if (tdp->t_name != NULL && strcmp(tdp->t_name, name1) == 0) {
+ if (tdp->t_name != NULL && strcmp(tdp->t_name, name) == 0) {
if (tdp->t_type == STRUCT || tdp->t_type == UNION ||
tdp->t_type == ENUM || tdp->t_type == INTRINSIC)
return (tdp);
@@ -1056,9 +1057,9 @@ lookup_name(tdesc_t **hash, const char *name1)
}
tdesc_t *
-lookupname(const char *name1)
+lookupname(const char *name)
{
- return (lookup_name(name_table, name1));
+ return (lookup_name(name_table, name));
}
/*
@@ -1150,9 +1151,8 @@ check_hash(void)
/*ARGSUSED1*/
static int
-resolve_typed_bitfields_cb(void *arg, void *private __unused)
+resolve_typed_bitfields_cb(mlist_t *ml, void *private)
{
- mlist_t *ml = arg;
tdesc_t *tdp = ml->ml_type;
debug(3, "Resolving typed bitfields (member %s)\n",
@@ -1194,5 +1194,5 @@ void
resolve_typed_bitfields(void)
{
(void) list_iter(typedbitfldmems,
- resolve_typed_bitfields_cb, NULL);
+ (int (*)())resolve_typed_bitfields_cb, NULL);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c b/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
index c0c68b5..f7b3034 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
@@ -47,7 +47,7 @@
#include "memory.h"
#include "traverse.h"
-char *curhdr;
+const char *curhdr;
/*
* The stabs generator will sometimes reference types before they've been
@@ -59,7 +59,7 @@ char *curhdr;
*/
/*ARGSUSED2*/
static int
-resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private __unused)
+resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private)
{
tdesc_t *new;
@@ -79,7 +79,7 @@ resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private __unused)
/*ARGSUSED*/
static int
-resolve_fwd_node(tdesc_t *node, tdesc_t **nodep, void *private __unused)
+resolve_fwd_node(tdesc_t *node, tdesc_t **nodep, void *private)
{
tdesc_t *new = lookupname(node->t_name);
@@ -174,7 +174,7 @@ fnarg_free(iidesc_t *ii)
* assembled under an iidesc list.
*/
int
-stabs_read(tdata_t *td, Elf *elf, char *file)
+stabs_read(tdata_t *td, Elf *elf, const char *file)
{
Elf_Scn *scn;
Elf_Data *data;
@@ -200,7 +200,7 @@ stabs_read(tdata_t *td, Elf *elf, char *file)
file_stack = stack_new(free);
- stack_push(file_stack, file);
+ stack_push(file_stack, (void *)file);
curhdr = file;
debug(3, "Found stabs in %d, strings in %d\n", stabidx, stabstridx);
@@ -255,7 +255,7 @@ stabs_read(tdata_t *td, Elf *elf, char *file)
if (stab->n_type == N_BINCL) {
curhdr = xstrdup(str);
- stack_push(file_stack, curhdr);
+ stack_push(file_stack, (void *)curhdr);
continue;
} else if (stab->n_type == N_SO) {
if (str[strlen(str) - 1] != '/') {
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
index d8b2bf0..ba6b7d8 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
@@ -205,7 +205,7 @@ strtab_size(const strtab_t *sp)
ssize_t
strtab_write(const strtab_t *sp,
- ssize_t (*func)(void *, size_t, void *), void *priv)
+ ssize_t (*func)(const void *, size_t, void *), void *priv)
{
ssize_t res, total = 0;
ulong_t i;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
index 13c1e59..7176e07 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
@@ -59,7 +59,7 @@ extern void strtab_destroy(strtab_t *);
extern size_t strtab_insert(strtab_t *, const char *);
extern size_t strtab_size(const strtab_t *);
extern ssize_t strtab_write(const strtab_t *,
- ssize_t (*)(void *, size_t, void *), void *);
+ ssize_t (*)(const void *, size_t, void *), void *);
extern void strtab_print(const strtab_t *);
#ifdef __cplusplus
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
index 4a0cc79..32d8482 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
@@ -174,10 +174,9 @@ tdesc_namecmp(void *arg1, void *arg2)
return (!streq(tdp1->t_name, tdp2->t_name));
}
-#if defined(sun)
/*ARGSUSED1*/
-static int
-tdesc_print(void *data, void *private __unused)
+int
+tdesc_print(void *data, void *private)
{
tdesc_t *tdp = data;
@@ -185,7 +184,6 @@ tdesc_print(void *data, void *private __unused)
return (1);
}
-#endif
static void
free_intr(tdesc_t *tdp)
@@ -249,42 +247,39 @@ static void (*free_cbs[])(tdesc_t *) = {
};
/*ARGSUSED1*/
-static void
-tdesc_free_cb(void *arg, void *private __unused)
+static int
+tdesc_free_cb(tdesc_t *tdp, void *private)
{
- tdesc_t *tdp = arg;
if (tdp->t_name)
free(tdp->t_name);
if (free_cbs[tdp->t_type])
free_cbs[tdp->t_type](tdp);
free(tdp);
- return;
+ return (1);
}
void
tdesc_free(tdesc_t *tdp)
{
- tdesc_free_cb(tdp, NULL);
+ (void) tdesc_free_cb(tdp, NULL);
}
static int
-tdata_label_cmp(void *arg1, void *arg2)
+tdata_label_cmp(labelent_t *le1, labelent_t *le2)
{
- labelent_t *le1 = arg1;
- labelent_t *le2 = arg2;
return (le1->le_idx - le2->le_idx);
}
void
-tdata_label_add(tdata_t *td, const char *label, int idx)
+tdata_label_add(tdata_t *td, char *label, int idx)
{
labelent_t *le = xmalloc(sizeof (*le));
le->le_name = xstrdup(label);
le->le_idx = (idx == -1 ? td->td_nextid - 1 : idx);
- slist_add(&td->td_labels, le, tdata_label_cmp);
+ slist_add(&td->td_labels, le, (int (*)())tdata_label_cmp);
}
static int
@@ -309,10 +304,8 @@ tdata_label_top(tdata_t *td)
}
static int
-tdata_label_find_cb(void *arg1, void *arg2)
+tdata_label_find_cb(labelent_t *le, labelent_t *tmpl)
{
- labelent_t *le = arg1;
- labelent_t *tmpl = arg2;
return (streq(le->le_name, tmpl->le_name));
}
@@ -330,7 +323,7 @@ tdata_label_find(tdata_t *td, char *label)
let.le_name = label;
if (!(ret = (labelent_t *)list_find(td->td_labels, &let,
- tdata_label_find_cb)))
+ (int (*)())tdata_label_find_cb)))
return (-1);
return (ret->le_idx);
@@ -358,9 +351,8 @@ tdata_label_newmax(tdata_t *td, int newmax)
/*ARGSUSED1*/
static void
-tdata_label_free_cb(void *arg, void *private __unused)
+tdata_label_free_cb(labelent_t *le, void *private)
{
- labelent_t *le = arg;
if (le->le_name)
free(le->le_name);
free(le);
@@ -369,7 +361,7 @@ tdata_label_free_cb(void *arg, void *private __unused)
void
tdata_label_free(tdata_t *td)
{
- list_free(td->td_labels, tdata_label_free_cb, NULL);
+ list_free(td->td_labels, (void (*)())tdata_label_free_cb, NULL);
td->td_labels = NULL;
}
@@ -399,8 +391,8 @@ tdata_new(void)
void
tdata_free(tdata_t *td)
{
- hash_free(td->td_iihash, iidesc_free, NULL);
- hash_free(td->td_layouthash, tdesc_free_cb, NULL);
+ hash_free(td->td_iihash, (void (*)())iidesc_free, NULL);
+ hash_free(td->td_layouthash, (void (*)())tdesc_free_cb, NULL);
hash_free(td->td_idhash, NULL, NULL);
list_free(td->td_fwdlist, NULL, NULL);
@@ -416,7 +408,7 @@ tdata_free(tdata_t *td)
/*ARGSUSED1*/
static int
-build_hashes(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
+build_hashes(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
{
tdata_t *td = private;
@@ -473,7 +465,7 @@ tdata_merge(tdata_t *td1, tdata_t *td2)
td2->td_fwdlist = NULL;
slist_merge(&td1->td_labels, td2->td_labels,
- tdata_label_cmp);
+ (int (*)())tdata_label_cmp);
td2->td_labels = NULL;
/* free the td2 hashes (data is now part of td1) */
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
index feb9908..b415b35 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
@@ -37,8 +37,10 @@
#include "traverse.h"
#include "memory.h"
-int (*tddescenders[])(tdesc_t *, tdtrav_data_t *);
-tdtrav_cb_f tdnops[];
+int (*tddescenders[])();
+int (*tdnops[])();
+
+int tdtraverse(tdesc_t *, tdesc_t **, tdtrav_data_t *);
void
tdtrav_init(tdtrav_data_t *tdtd, int *vgenp, tdtrav_cb_f *firstops,
@@ -66,7 +68,7 @@ tdtrav_func(tdesc_t *this, tdtrav_data_t *tdtd)
if ((rc = tdtraverse(fn->fn_ret, &fn->fn_ret, tdtd)) < 0)
return (rc);
- for (i = 0; i < (int) fn->fn_nargs; i++) {
+ for (i = 0; i < fn->fn_nargs; i++) {
if ((rc = tdtraverse(fn->fn_args[i], &fn->fn_args[i],
tdtd)) < 0)
return (rc);
@@ -104,7 +106,7 @@ tdtrav_su(tdesc_t *this, tdtrav_data_t *tdtd)
/*ARGSUSED*/
int
-tdtrav_assert(tdesc_t *node __unused, tdesc_t **nodep __unused, void *private __unused)
+tdtrav_assert(tdesc_t *node, tdesc_t **nodep, void *private)
{
assert(1 == 0);
@@ -149,7 +151,7 @@ int
tdtraverse(tdesc_t *this, tdesc_t **thisp, tdtrav_data_t *tdtd)
{
tdtrav_cb_f travcb;
- int (*descender)(tdesc_t *, tdtrav_data_t *);
+ int (*descender)();
int descend = 1;
int rc;
@@ -185,10 +187,8 @@ tdtraverse(tdesc_t *this, tdesc_t **thisp, tdtrav_data_t *tdtd)
}
int
-iitraverse_td(void *arg1, void *arg2)
+iitraverse_td(iidesc_t *ii, tdtrav_data_t *tdtd)
{
- iidesc_t *ii = arg1;
- tdtrav_data_t *tdtd = arg2;
int i, rc;
if ((rc = tdtraverse(ii->ii_dtype, &ii->ii_dtype, tdtd)) < 0)
@@ -222,5 +222,5 @@ iitraverse_hash(hash_t *iihash, int *vgenp, tdtrav_cb_f *firstops,
tdtrav_init(&tdtd, vgenp, firstops, preops, postops, private);
- return (hash_iter(iihash, iitraverse_td, &tdtd));
+ return (hash_iter(iihash, (int (*)())iitraverse_td, &tdtd));
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
index 6a56370..0f8396f 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
@@ -60,7 +60,7 @@ int iitraverse(iidesc_t *, int *, tdtrav_cb_f *, tdtrav_cb_f *, tdtrav_cb_f *,
void *);
int iitraverse_hash(hash_t *, int *, tdtrav_cb_f *, tdtrav_cb_f *,
tdtrav_cb_f *, void *);
-int iitraverse_td(void *, void *);
+int iitraverse_td(iidesc_t *ii, tdtrav_data_t *);
int tdtrav_assert(tdesc_t *, tdesc_t **, void *);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/util.c b/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
index 0f36fa0..799ca12 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
@@ -43,7 +43,7 @@
#include "ctftools.h"
#include "memory.h"
-static void (*terminate_cleanup)(void) = NULL;
+static void (*terminate_cleanup)() = NULL;
/* returns 1 if s1 == s2, 0 otherwise */
int
@@ -116,7 +116,7 @@ elf_ptrsz(Elf *elf)
/*PRINTFLIKE2*/
static void
-whine(const char *type, const char *format, va_list ap)
+whine(char *type, char *format, va_list ap)
{
int error = errno;
@@ -128,14 +128,14 @@ whine(const char *type, const char *format, va_list ap)
}
void
-set_terminate_cleanup(void (*cleanup)(void))
+set_terminate_cleanup(void (*cleanup)())
{
terminate_cleanup = cleanup;
}
/*PRINTFLIKE1*/
void
-terminate(const char *format, ...)
+terminate(char *format, ...)
{
va_list ap;
@@ -148,22 +148,12 @@ terminate(const char *format, ...)
if (getenv("CTF_ABORT_ON_TERMINATE") != NULL)
abort();
-#if defined(__FreeBSD__)
-/*
- * For the time being just output the termination message, but don't
- * return an exit status that would cause the build to fail. We need
- * to get as much stuff built as possible before going back and
- * figuring out what is wrong with certain files.
- */
- exit(0);
-#else
exit(1);
-#endif
}
/*PRINTFLIKE1*/
void
-aborterr(const char *format, ...)
+aborterr(char *format, ...)
{
va_list ap;
@@ -171,16 +161,12 @@ aborterr(const char *format, ...)
whine("ERROR", format, ap);
va_end(ap);
-#if defined(sun)
abort();
-#else
- exit(0);
-#endif
}
/*PRINTFLIKE1*/
void
-warning(const char *format, ...)
+warning(char *format, ...)
{
va_list ap;
@@ -194,7 +180,7 @@ warning(const char *format, ...)
/*PRINTFLIKE2*/
void
-vadebug(int level, const char *format, va_list ap)
+vadebug(int level, char *format, va_list ap)
{
if (level > debug_level)
return;
@@ -206,7 +192,7 @@ vadebug(int level, const char *format, va_list ap)
/*PRINTFLIKE2*/
void
-debug(int level, const char *format, ...)
+debug(int level, char *format, ...)
{
va_list ap;
@@ -248,36 +234,3 @@ tdesc_name(tdesc_t *tdp)
{
return (tdp->t_name == NULL ? "(anon)" : tdp->t_name);
}
-
-char *watch_address = NULL;
-int watch_length = 0;
-
-void
-watch_set(void *addr, int len)
-{
- watch_address = addr;
- watch_length = len;
-}
-
-void
-watch_dump(int v)
-{
- char *p = watch_address;
- int i;
-
- if (watch_address == NULL || watch_length == 0)
- return;
-
- printf("%d: watch %p len %d\n",v,watch_address,watch_length);
- for (i = 0; i < watch_length; i++) {
- if (*p >= 0x20 && *p < 0x7f) {
- printf(" %c",*p++ & 0xff);
- } else {
- printf(" %02x",*p++ & 0xff);
- }
- }
- printf("\n");
-
-}
-
-
diff --git a/cddl/contrib/opensolaris/tools/ctf/dump/dump.c b/cddl/contrib/opensolaris/tools/ctf/dump/dump.c
index 740485d..5579bae 100644
--- a/cddl/contrib/opensolaris/tools/ctf/dump/dump.c
+++ b/cddl/contrib/opensolaris/tools/ctf/dump/dump.c
@@ -203,8 +203,9 @@ print_header(const ctf_header_t *hp, const ctf_data_t *cd)
static int
print_labeltable(const ctf_header_t *hp, const ctf_data_t *cd)
{
- void *v = (void *) (cd->cd_ctfdata + hp->cth_lbloff);
- const ctf_lblent_t *ctl = v;
+ /* LINTED - pointer alignment */
+ const ctf_lblent_t *ctl = (ctf_lblent_t *)(cd->cd_ctfdata +
+ hp->cth_lbloff);
ulong_t i, n = (hp->cth_objtoff - hp->cth_lbloff) / sizeof (*ctl);
print_line("- Label Table ");
@@ -266,8 +267,8 @@ next_sym(const ctf_data_t *cd, const int symidx, const uchar_t matchtype,
static int
read_data(const ctf_header_t *hp, const ctf_data_t *cd)
{
- void *v = (void *) (cd->cd_ctfdata + hp->cth_objtoff);
- const ushort_t *idp = v;
+ /* LINTED - pointer alignment */
+ const ushort_t *idp = (ushort_t *)(cd->cd_ctfdata + hp->cth_objtoff);
ulong_t n = (hp->cth_funcoff - hp->cth_objtoff) / sizeof (ushort_t);
if (flags != F_STATS)
@@ -286,7 +287,7 @@ read_data(const ctf_header_t *hp, const ctf_data_t *cd)
int symidx, len, i;
char *name = NULL;
- for (symidx = -1, i = 0; i < (int) n; i++) {
+ for (symidx = -1, i = 0; i < n; i++) {
int nextsym;
if (cd->cd_symdata == NULL || (nextsym = next_sym(cd,
@@ -310,11 +311,11 @@ read_data(const ctf_header_t *hp, const ctf_data_t *cd)
static int
read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
{
- void *v = (void *) (cd->cd_ctfdata + hp->cth_funcoff);
- const ushort_t *fp = v;
+ /* LINTED - pointer alignment */
+ const ushort_t *fp = (ushort_t *)(cd->cd_ctfdata + hp->cth_funcoff);
- v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
- const ushort_t *end = v;
+ /* LINTED - pointer alignment */
+ const ushort_t *end = (ushort_t *)(cd->cd_ctfdata + hp->cth_typeoff);
ulong_t id;
int symidx;
@@ -387,11 +388,11 @@ read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
static int
read_types(const ctf_header_t *hp, const ctf_data_t *cd)
{
- void *v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
- const ctf_type_t *tp = v;
+ /* LINTED - pointer alignment */
+ const ctf_type_t *tp = (ctf_type_t *)(cd->cd_ctfdata + hp->cth_typeoff);
- v = (void *) (cd->cd_ctfdata + hp->cth_stroff);
- const ctf_type_t *end = v;
+ /* LINTED - pointer alignment */
+ const ctf_type_t *end = (ctf_type_t *)(cd->cd_ctfdata + hp->cth_stroff);
ulong_t id;
@@ -418,7 +419,7 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
union {
const void *ptr;
- ctf_array_t *ap;
+ const ctf_array_t *ap;
const ctf_member_t *mp;
const ctf_lmember_t *lmp;
const ctf_enum_t *ep;
@@ -438,7 +439,7 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
increment = sizeof (ctf_stype_t);
size = tp->ctt_size;
}
- u.ptr = (const char *)tp + increment;
+ u.ptr = (caddr_t)tp + increment;
switch (kind) {
case CTF_K_INTEGER:
@@ -526,7 +527,7 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
}
if (flags != F_STATS) {
- (void) printf(" %s (%zd bytes)\n",
+ (void) printf(" %s (%d bytes)\n",
ref_to_str(tp->ctt_name, hp, cd), size);
if (size >= CTF_LSTRUCT_THRESH) {
@@ -535,7 +536,6 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
"\t%s type=%u off=%llu\n",
ref_to_str(u.lmp->ctlm_name,
hp, cd), u.lmp->ctlm_type,
- (unsigned long long)
CTF_LMEM_OFFSET(u.lmp));
}
} else {
@@ -785,7 +785,7 @@ print_usage(FILE *fp, int verbose)
}
static Elf_Scn *
-findelfscn(Elf *elf, GElf_Ehdr *ehdr, const char *secname)
+findelfscn(Elf *elf, GElf_Ehdr *ehdr, char *secname)
{
GElf_Shdr shdr;
Elf_Scn *scn;
@@ -811,7 +811,7 @@ main(int argc, char *argv[])
ctf_data_t cd;
const ctf_preamble_t *pp;
- ctf_header_t *hp = NULL;
+ ctf_header_t *hp;
Elf *elf;
GElf_Ehdr ehdr;
@@ -871,7 +871,7 @@ main(int argc, char *argv[])
if ((elf = elf_begin(fd, ELF_C_READ, NULL)) != NULL &&
gelf_getehdr(elf, &ehdr) != NULL) {
- Elf_Data *dp = NULL;
+ Elf_Data *dp;
Elf_Scn *ctfscn = findelfscn(elf, &ehdr, ".SUNW_ctf");
Elf_Scn *symscn;
GElf_Shdr ctfshdr;
@@ -929,15 +929,15 @@ main(int argc, char *argv[])
if (cd.cd_ctflen < sizeof (ctf_preamble_t))
die("%s does not contain a CTF preamble\n", filename);
- void *v = (void *) cd.cd_ctfdata;
- pp = v;
+ /* LINTED - pointer alignment */
+ pp = (const ctf_preamble_t *)cd.cd_ctfdata;
if (pp->ctp_magic != CTF_MAGIC)
die("%s does not appear to contain CTF data\n", filename);
if (pp->ctp_version == CTF_VERSION) {
- v = (void *) cd.cd_ctfdata;
- hp = v;
+ /* LINTED - pointer alignment */
+ hp = (ctf_header_t *)cd.cd_ctfdata;
cd.cd_ctfdata = (caddr_t)cd.cd_ctfdata + sizeof (ctf_header_t);
if (cd.cd_ctflen < sizeof (ctf_header_t)) {
@@ -1012,7 +1012,7 @@ main(int argc, char *argv[])
if ((ufd = open(ufile, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0 ||
write(ufd, &h, sizeof (h)) != sizeof (h) ||
- write(ufd, cd.cd_ctfdata, cd.cd_ctflen) != (int) cd.cd_ctflen) {
+ write(ufd, cd.cd_ctfdata, cd.cd_ctflen) != cd.cd_ctflen) {
warn("failed to write CTF data to '%s'", ufile);
error |= E_ERROR;
}
OpenPOWER on IntegriCloud