Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet check and fix printf formats, negative a...



details:   https://anonhg.NetBSD.org/src/rev/85a36b2b3391
branches:  trunk
changeset: 806180:85a36b2b3391
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Feb 07 20:30:03 2015 +0000

description:
check and fix printf formats, negative array indices, uninitialized variables,
shadowed variables.

diffstat:

 external/cddl/osnet/Makefile.inc                             |    2 +
 external/cddl/osnet/dist/cmd/dtrace/dtrace.c                 |   38 +-
 external/cddl/osnet/dist/common/ctf/ctf_create.c             |   14 +-
 external/cddl/osnet/dist/common/ctf/ctf_hash.c               |    2 +-
 external/cddl/osnet/dist/common/ctf/ctf_labels.c             |    8 +-
 external/cddl/osnet/dist/common/ctf/ctf_lookup.c             |    6 +-
 external/cddl/osnet/dist/common/ctf/ctf_open.c               |   14 +-
 external/cddl/osnet/dist/common/ctf/ctf_types.c              |    2 +-
 external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c         |    2 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c |   52 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_as.c        |    5 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_cc.c        |    8 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_cg.c        |    4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c   |   47 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_dis.c       |    2 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_dof.c       |   32 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_ident.c     |    4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_lex.l       |    4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c      |    2 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_list.h      |    4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c    |    4 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c      |    6 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c   |    2 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_parser.c    |   10 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c       |   10 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_pragma.c    |    4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c    |   14 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c      |   15 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_program.c   |    2 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c      |    4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_work.c      |    1 +
 external/cddl/osnet/dist/lib/libgen/common/gmatch.c          |    1 +
 external/cddl/osnet/dist/tools/ctf/cvt/ctf.c                 |   20 +-
 external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c            |   43 +-
 external/cddl/osnet/dist/tools/ctf/cvt/ctftools.h            |   10 +-
 external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c               |  168 ++++++----
 external/cddl/osnet/dist/tools/ctf/cvt/st_parse.c            |   14 +-
 external/cddl/osnet/dist/tools/ctf/cvt/stabs.c               |    2 +-
 external/cddl/osnet/dist/tools/ctf/cvt/util.c                |    4 +-
 external/cddl/osnet/lib/libdtrace/Makefile                   |    3 +-
 external/cddl/osnet/sys/sys/sysmacros.h                      |   12 +-
 41 files changed, 340 insertions(+), 261 deletions(-)

diffs (truncated from 2089 to 300 lines):

diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/Makefile.inc
--- a/external/cddl/osnet/Makefile.inc  Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/Makefile.inc  Sat Feb 07 20:30:03 2015 +0000
@@ -1,6 +1,8 @@
 # $FreeBSD: src/cddl/Makefile.inc,v 1.6.2.1 2009/08/03 08:13:06 kensmith Exp $
 
+WARNS?=5
 OSNETDIR=      ${NETBSDSRCDIR}/external/cddl/osnet
 
 OPENSOLARIS_USR_DISTDIR=${OSNETDIR}/dist
 OPENSOLARIS_SYS_DISTDIR=${OSNETDIR}/dist
+CPPFLAGS+=-Wno-unknown-pragmas -Wno-sign-compare
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/cmd/dtrace/dtrace.c
--- a/external/cddl/osnet/dist/cmd/dtrace/dtrace.c      Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/cmd/dtrace/dtrace.c      Sat Feb 07 20:30:03 2015 +0000
@@ -850,16 +850,16 @@
 #define        BUFDUMPSTR(ptr, field) \
        (void) printf("%s: %20s => ", g_pname, #field); \
        if ((ptr)->field != NULL) {                     \
-               const char *c = (ptr)->field;           \
+               const char *xc = (ptr)->field;          \
                (void) printf("\"");                    \
                do {                                    \
-                       if (*c == '\n') {               \
+                       if (*xc == '\n') {              \
                                (void) printf("\\n");   \
                                continue;               \
                        }                               \
                                                        \
-                       (void) printf("%c", *c);        \
-               } while (*c++ != '\0');                 \
+                       (void) printf("%c", *xc);       \
+               } while (*xc++ != '\0');                \
                (void) printf("\"\n");                  \
        } else {                                        \
                (void) printf("<NULL>\n");              \
@@ -1084,18 +1084,18 @@
        int i;
 
        struct {
-               char *name;
-               char *optname;
+               const char *name;
+               const char *optname;
                dtrace_optval_t val;
        } bufs[] = {
-               { "buffer size", "bufsize" },
-               { "aggregation size", "aggsize" },
-               { "speculation size", "specsize" },
-               { "dynamic variable size", "dynvarsize" },
+               { "buffer size", "bufsize", 0 },
+               { "aggregation size", "aggsize", 0 },
+               { "speculation size", "specsize", 0 },
+               { "dynamic variable size", "dynvarsize", 0 },
                { NULL }
        }, rates[] = {
-               { "cleaning rate", "cleanrate" },
-               { "status rate", "statusrate" },
+               { "cleaning rate", "cleanrate", 0 },
+               { "status rate", "statusrate", 0 },
                { NULL }
        };
 
@@ -1141,7 +1141,7 @@
 
        for (i = 0; rates[i].name != NULL; i++) {
                dtrace_optval_t nval;
-               char *dir;
+               const char *dir;
 
                if (rates[i].val == DTRACEOPT_UNSET)
                        continue;
@@ -1761,7 +1761,7 @@
                }
 
                if (g_ofile == NULL) {
-                       char *p;
+                       char *pv;
 
                        if (g_cmdc > 1) {
                                (void) fprintf(stderr, "%s: -h requires an "
@@ -1771,8 +1771,8 @@
                                return (E_USAGE);
                        }
 
-                       if ((p = strrchr(g_cmdv[0].dc_arg, '.')) == NULL ||
-                           strcmp(p, ".d") != 0) {
+                       if ((pv = strrchr(g_cmdv[0].dc_arg, '.')) == NULL ||
+                           strcmp(pv, ".d") != 0) {
                                (void) fprintf(stderr, "%s: -h requires an "
                                    "output file if no scripts are "
                                    "specified\n", g_pname);
@@ -1780,9 +1780,9 @@
                                return (E_USAGE);
                        }
 
-                       p[0] = '\0'; /* strip .d suffix */
-                       g_ofile = p = g_cmdv[0].dc_ofile;
-                       (void) snprintf(p, sizeof (g_cmdv[0].dc_ofile),
+                       pv[0] = '\0'; /* strip .d suffix */
+                       g_ofile = pv = g_cmdv[0].dc_ofile;
+                       (void) snprintf(pv, sizeof (g_cmdv[0].dc_ofile),
                            "%s.h", basename(g_cmdv[0].dc_arg));
                }
 
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/common/ctf/ctf_create.c
--- a/external/cddl/osnet/dist/common/ctf/ctf_create.c  Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/common/ctf/ctf_create.c  Sat Feb 07 20:30:03 2015 +0000
@@ -50,7 +50,11 @@
 ctf_file_t *
 ctf_create(int *errp)
 {
-       static const ctf_header_t hdr = { { CTF_MAGIC, CTF_VERSION, 0 } };
+       static const ctf_header_t hdr = { .cth_preamble = {
+               .ctp_magic = CTF_MAGIC,
+               .ctp_version = CTF_VERSION,
+               .ctp_flags = 0
+       } };
 
        const ulong_t hashlen = 128;
        ctf_dtdef_t **hash = ctf_alloc(hashlen * sizeof (ctf_dtdef_t *));
@@ -60,10 +64,10 @@
        if (hash == NULL)
                return (ctf_set_open_errno(errp, EAGAIN));
 
-       cts.cts_name = (char *)_CTF_SECTION;
+       cts.cts_name = __UNCONST(_CTF_SECTION);
        cts.cts_type = SHT_PROGBITS;
        cts.cts_flags = 0;
-       cts.cts_data = (ctf_header_t *)&hdr;
+       cts.cts_data = __UNCONST(&hdr);
        cts.cts_size = sizeof (hdr);
        cts.cts_entsize = 1;
        cts.cts_offset = 0;
@@ -364,7 +368,7 @@
         * is successful, we then switch nfp and fp and free the old container.
         */
        ctf_data_protect(buf, size);
-       cts.cts_name = (char *)_CTF_SECTION;
+       cts.cts_name = __UNCONST(_CTF_SECTION);
        cts.cts_type = SHT_PROGBITS;
        cts.cts_flags = 0;
        cts.cts_data = buf;
@@ -500,7 +504,7 @@
 int
 ctf_discard(ctf_file_t *fp)
 {
-       ctf_dtdef_t *dtd, *ntd;
+       ctf_dtdef_t *dtd, *ntd = NULL;
 
        if (!(fp->ctf_flags & LCTF_RDWR))
                return (ctf_set_errno(fp, ECTF_RDONLY));
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/common/ctf/ctf_hash.c
--- a/external/cddl/osnet/dist/common/ctf/ctf_hash.c    Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/common/ctf/ctf_hash.c    Sat Feb 07 20:30:03 2015 +0000
@@ -43,7 +43,7 @@
         */
        if (nelems == 0) {
                bzero(hp, sizeof (ctf_hash_t));
-               hp->h_buckets = (ushort_t *)_CTF_EMPTY;
+               hp->h_buckets = __UNCONST(_CTF_EMPTY);
                hp->h_nbuckets = 1;
                return (0);
        }
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/common/ctf/ctf_labels.c
--- a/external/cddl/osnet/dist/common/ctf/ctf_labels.c  Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/common/ctf/ctf_labels.c  Sat Feb 07 20:30:03 2015 +0000
@@ -54,9 +54,9 @@
 const char *
 ctf_label_topmost(ctf_file_t *fp)
 {
-       const ctf_lblent_t *ctlp;
+       const ctf_lblent_t *ctlp = NULL;
        const char *s;
-       uint_t num_labels;
+       uint_t num_labels = 0;
 
        if (extract_label_info(fp, &ctlp, &num_labels) == CTF_ERR)
                return (NULL); /* errno is set */
@@ -79,8 +79,8 @@
 int
 ctf_label_iter(ctf_file_t *fp, ctf_label_f *func, void *arg)
 {
-       const ctf_lblent_t *ctlp;
-       uint_t i, num_labels;
+       const ctf_lblent_t *ctlp = NULL;
+       uint_t i, num_labels = 0;
        ctf_lblinfo_t linfo;
        const char *lname;
        int rc;
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/common/ctf/ctf_lookup.c
--- a/external/cddl/osnet/dist/common/ctf/ctf_lookup.c  Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/common/ctf/ctf_lookup.c  Sat Feb 07 20:30:03 2015 +0000
@@ -90,7 +90,7 @@
                return (ctf_set_errno(fp, EINVAL));
 
        for (p = name, end = name + strlen(name); *p != '\0'; p = q) {
-               while (isspace(*p))
+               while (isspace((unsigned char)*p))
                        p++; /* skip leading ws */
 
                if (p == end)
@@ -132,13 +132,13 @@
                for (lp = fp->ctf_lookups; lp->ctl_prefix != NULL; lp++) {
                        if (lp->ctl_prefix[0] == '\0' ||
                            strncmp(p, lp->ctl_prefix, (size_t)(q - p)) == 0) {
-                               for (p += lp->ctl_len; isspace(*p); p++)
+                               for (p += lp->ctl_len; isspace((unsigned char)*p); p++)
                                        continue; /* skip prefix and next ws */
 
                                if ((q = strchr(p, '*')) == NULL)
                                        q = end;  /* compare until end */
 
-                               while (isspace(q[-1]))
+                               while (isspace((unsigned char)q[-1]))
                                        q--;      /* exclude trailing ws */
 
                                if ((hp = ctf_hash_lookup(lp->ctl_hash, fp, p,
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/common/ctf/ctf_open.c
--- a/external/cddl/osnet/dist/common/ctf/ctf_open.c    Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/common/ctf/ctf_open.c    Sat Feb 07 20:30:03 2015 +0000
@@ -80,7 +80,7 @@
 }
 
 static const ctf_fileops_t ctf_fileops[] = {
-       { NULL, NULL },
+       { NULL, NULL, NULL },
        { get_kind_v1, get_root_v1, get_vlen_v1 },
        { get_kind_v2, get_root_v2, get_vlen_v2 },
 };
@@ -199,9 +199,9 @@
 init_types(ctf_file_t *fp, const ctf_header_t *cth)
 {
        /* LINTED - pointer alignment */
-       const ctf_type_t *tbuf = (ctf_type_t *)(fp->ctf_buf + cth->cth_typeoff);
+       const ctf_type_t *tbuf = (const ctf_type_t *)(fp->ctf_buf + cth->cth_typeoff);
        /* LINTED - pointer alignment */
-       const ctf_type_t *tend = (ctf_type_t *)(fp->ctf_buf + cth->cth_stroff);
+       const ctf_type_t *tend = (const ctf_type_t *)(fp->ctf_buf + cth->cth_stroff);
 
        ulong_t pop[CTF_K_MAX + 1] = { 0 };
        const ctf_type_t *tp;
@@ -694,11 +694,11 @@
                fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name);
 
        if (fp->ctf_data.cts_name == NULL)
-               fp->ctf_data.cts_name = (char *)_CTF_NULLSTR;
+               fp->ctf_data.cts_name = __UNCONST(_CTF_NULLSTR);
        if (fp->ctf_symtab.cts_name == NULL)
-               fp->ctf_symtab.cts_name = (char *)_CTF_NULLSTR;
+               fp->ctf_symtab.cts_name = __UNCONST(_CTF_NULLSTR);
        if (fp->ctf_strtab.cts_name == NULL)
-               fp->ctf_strtab.cts_name = (char *)_CTF_NULLSTR;
+               fp->ctf_strtab.cts_name = __UNCONST(_CTF_NULLSTR);
 
        fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff;
        fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen;
@@ -845,7 +845,7 @@
        }
 
        if (fp->ctf_base != fp->ctf_data.cts_data && fp->ctf_base != NULL)
-               ctf_data_free((void *)fp->ctf_base, fp->ctf_size);
+               ctf_data_free(__UNCONST(fp->ctf_base), fp->ctf_size);
 
        if (fp->ctf_sxlate != NULL)
                ctf_free(fp->ctf_sxlate, sizeof (uint_t) * fp->ctf_nsyms);
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/common/ctf/ctf_types.c
--- a/external/cddl/osnet/dist/common/ctf/ctf_types.c   Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/common/ctf/ctf_types.c   Sat Feb 07 20:30:03 2015 +0000
@@ -395,7 +395,7 @@
                const void *vmp;
 
                (void) ctf_get_ctt_size(fp, tp, &size, &increment);
-               vmp = (uchar_t *)tp + increment;
+               vmp = (const uchar_t *)tp + increment;
 
                if (LCTF_INFO_KIND(fp, tp->ctt_info) == CTF_K_STRUCT)
                        n = MIN(n, 1); /* only use first member for structs */
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c
--- a/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c      Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c      Sat Feb 07 20:30:03 2015 +0000
@@ -256,7 +256,7 @@
                if (ctfsect.cts_data == MAP_FAILED)
                        return (ctf_set_open_errno(errp, errno));
 
-               ctfsect.cts_name = (char *)_CTF_SECTION;
+               ctfsect.cts_name = __UNCONST(_CTF_SECTION);
                ctfsect.cts_type = SHT_PROGBITS;
                ctfsect.cts_flags = SHF_ALLOC;
                ctfsect.cts_size = (size_t)st.st_size;
diff -r 9e23906248f0 -r 85a36b2b3391 external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c
--- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c      Sat Feb 07 20:01:48 2015 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c      Sat Feb 07 20:30:03 2015 +0000
@@ -213,7 +213,7 @@
 {
        int nbuckets = DTRACE_QUANTIZE_NBUCKETS;
        long double ltotal = 0, rtotal = 0;
-       int64_t lzero, rzero;
+       int64_t lzero = 0, rzero = 0;
        uint_t i;



Home | Main Index | Thread Index | Old Index