[DTrace-devel] [PATCH] Clean up compiler warnings

Eugene Loh eugene.loh at oracle.com
Tue Aug 18 18:02:15 PDT 2020


Initially posted four weeks ago, but I don't think I've seen a response.


On 08/11/2020 03:21 PM, Eugene Loh wrote:
> Review, please.
>
>
> On 07/21/2020 05:11 PM, eugene.loh at oracle.com wrote:
>> From: Eugene Loh <eugene.loh at oracle.com>
>>
>> Address compiler warnings, which are often due to our "#ifdef FIXME"
>> or other (sometimes temporarily) orphaned code.  Here is wc output on
>> "make" output:
>>           400  1293 16056 make_out.before
>>           228   474  6207 make_out.after
>> Clearly, the output is substantially reduced.  The remaining output
>> is much easier to read and makes it clear, whether during user build
>> or during development, what if anything is going wrong.
>>
>> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
>> ---
>>    bpf/get_bvar.c                    |  2 +-
>>    include/dtrace/fasttrap.h         |  4 +++-
>>    include/dtrace/fasttrap_defines.h | 22 ----------------------
>>    libdtrace/dt_cc.c                 |  8 ++++++--
>>    libdtrace/dt_cg.c                 | 16 +++++++++++++++-
>>    libdtrace/dt_consume.c            | 24 ++++++++++++++++++++++++
>>    libdtrace/dt_dof.c                |  8 ++++++++
>>    libdtrace/dt_pid.c                |  2 +-
>>    libdtrace/dt_subr.c               |  2 --
>>    libdtrace/dt_work.c               |  3 +--
>>    10 files changed, 59 insertions(+), 32 deletions(-)
>>    delete mode 100644 include/dtrace/fasttrap_defines.h
>>
>> diff --git a/bpf/get_bvar.c b/bpf/get_bvar.c
>> index 40045fb0..88726c22 100644
>> --- a/bpf/get_bvar.c
>> +++ b/bpf/get_bvar.c
>> @@ -56,7 +56,7 @@ noinline uint64_t dt_get_bvar(dt_mstate_t *mst, uint32_t id)
>>    	case DIF_VAR_CURCPU: {
>>    		uint32_t	key = 0;
>>    
>> -		return bpf_map_lookup_elem(&cpuinfo, &key);
>> +		return (uint64_t) bpf_map_lookup_elem(&cpuinfo, &key);
>>    	}
>>    	default:
>>    		/* Not implemented yet. */
>> diff --git a/include/dtrace/fasttrap.h b/include/dtrace/fasttrap.h
>> index 82877991..615ba81c 100644
>> --- a/include/dtrace/fasttrap.h
>> +++ b/include/dtrace/fasttrap.h
>> @@ -14,7 +14,9 @@
>>    #define _DTRACE_FASTTRAP_H
>>    
>>    #include <dtrace/universal.h>
>> -#include <dtrace/fasttrap_defines.h>
>> +
>> +struct fasttrap_probe_spec;
>> +struct fasttrap_instr_query;
>>    
>>    typedef enum fasttrap_probe_type {
>>    	DTFTP_NONE = 0,
>> diff --git a/include/dtrace/fasttrap_defines.h b/include/dtrace/fasttrap_defines.h
>> deleted file mode 100644
>> index a0d5e5fa..00000000
>> --- a/include/dtrace/fasttrap_defines.h
>> +++ /dev/null
>> @@ -1,22 +0,0 @@
>> -/*
>> - * Licensed under the Universal Permissive License v 1.0 as shown at
>> - * http://oss.oracle.com/licenses/upl.
>> - *
>> - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
>> - */
>> -
>> -/*
>> - * Note: The contents of this file are private to the implementation of the
>> - * DTrace subsystem and are subject to change at any time without notice.
>> - */
>> -
>> -#ifndef _DTRACE_FASTTRAP_DEFINES_H
>> -#define _DTRACE_FASTTRAP_DEFINES_H
>> -
>> -#include <dtrace/universal.h>
>> -
>> -enum fasttrap_probe_type;
>> -struct fasttrap_probe_spec;
>> -struct fasttrap_instr_query;
>> -
>> -#endif /* _DTRACE_FASTTRAP_DEFINES_H */
>> diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
>> index 10aa76e6..6d38c548 100644
>> --- a/libdtrace/dt_cc.c
>> +++ b/libdtrace/dt_cc.c
>> @@ -98,9 +98,11 @@ static const dtrace_diftype_t dt_void_rtype = {
>>    };
>>    #endif
>>    
>> +#ifdef FIXME
>>    static const dtrace_diftype_t dt_int_rtype = {
>>    	DIF_TYPE_CTF, CTF_K_INTEGER, 0, 0, sizeof (uint64_t)
>>    };
>> +#endif
>>    
>>    /*ARGSUSED*/
>>    static int
>> @@ -140,6 +142,7 @@ dt_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp,
>>    	return (sdp);
>>    }
>>    
>> +#ifdef FIXME
>>    /*
>>     * Utility function to determine if a given action description is destructive.
>>     * The dtdo_destructive bit is set for us by the DIF assembler (see dt_as.c).
>> @@ -150,17 +153,18 @@ dt_action_destructive(const dtrace_actdesc_t *ap)
>>    	return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) || (ap->dtad_kind ==
>>    	    DTRACEACT_DIFEXPR && ap->dtad_difo->dtdo_destructive));
>>    }
>> +#endif
>>    
>>    static void
>>    dt_stmt_append(dtrace_stmtdesc_t *sdp, const dt_node_t *dnp)
>>    {
>> +#ifdef FIXME
>>    	dtrace_ecbdesc_t *edp = sdp->dtsd_ecbdesc;
>>    	dtrace_actdesc_t *ap, *tap;
>>    	int commit = 0;
>>    	int speculate = 0;
>>    	int datarec = 0;
>>    
>> -#ifdef FIXME
>>    	/*
>>    	 * Make sure that the new statement jibes with the rest of the ECB.
>>    	 */
>> @@ -1599,7 +1603,7 @@ dt_clause_create(dtrace_hdl_t *dtp, const dtrace_difo_t *dp)
>>    	if (idp == NULL)
>>    		longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
>>    
>> -	dt_ident_set_data(idp, dp);
>> +	dt_ident_set_data(idp, (void *) dp);
>>    
>>    	return idp;
>>    }
>> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
>> index 2435b84d..68162926 100644
>> --- a/libdtrace/dt_cg.c
>> +++ b/libdtrace/dt_cg.c
>> @@ -579,10 +579,12 @@ dt_cg_act_exit(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>>    	dt_regset_free(pcb->pcb_regs, dnp->dn_args->dn_reg);
>>    }
>>    
>> +#if 0
>>    static void
>>    dt_cg_act_freopen(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>>    {
>>    }
>> +#endif
>>    
>>    static void
>>    dt_cg_act_ftruncate(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>> @@ -746,6 +748,11 @@ dt_cg_act_stack(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>>    
>>    		nframes = (uint32_t)arg->dn_value;
>>    	}
>> +
>> +	/* suppress compiler warning about unused variables
>> +	 * FIXME: remove assertion when variable is actually used.
>> +	 */
>> +	assert(nframes >= 0);
>>    }
>>    
>>    static void
>> @@ -760,10 +767,12 @@ dt_cg_act_symmod(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>>    {
>>    }
>>    
>> +#if 0
>>    static void
>>    dt_cg_act_system(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>>    {
>>    }
>> +#endif
>>    
>>    static void
>>    dt_cg_act_trace(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>> @@ -833,6 +842,11 @@ dt_cg_act_ustack(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>>    
>>    		strsize = (uint32_t)arg1->dn_value;
>>    	}
>> +
>> +	/* suppress compiler warning about unused variables
>> +	 * FIXME: remove assertion when variables are actually used.
>> +	 */
>> +	assert(nframes + strsize >= 0);
>>    }
>>    
>>    typedef void dt_cg_action_f(dt_pcb_t *, dt_node_t *, dtrace_actkind_t);
>> @@ -1926,7 +1940,6 @@ dt_cg_logical_neg(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>>    static void
>>    dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>>    {
>> -	struct bpf_insn instr;
>>    	dt_ident_t *idp;
>>    
>>    	/*
>> @@ -1937,6 +1950,7 @@ dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>>    	 */
>>    	if ((idp = dt_node_resolve(dnp->dn_right, DT_IDENT_XLSOU)) != NULL) {
>>    #ifdef FIXME
>> +		struct bpf_insn instr;
>>    		ctf_membinfo_t ctm;
>>    		dt_xlator_t *dxp = idp->di_data;
>>    		dt_node_t *mnp, dn, mn;
>> diff --git a/libdtrace/dt_consume.c b/libdtrace/dt_consume.c
>> index bd54ddee..58fe6ad1 100644
>> --- a/libdtrace/dt_consume.c
>> +++ b/libdtrace/dt_consume.c
>> @@ -379,6 +379,13 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
>>    	dtrace_epid_t		id = data->dtpda_epid;
>>    	int			rval;
>>    
>> +	/* suppress compiler warning about "unused variable"
>> +	 * FIXME: remove assertion when
>> +	 * - we actually use dd, or
>> +	 * - we remove dd
>> +	 */
>> +	assert(dd || dd == NULL);
>> +
>>    	if (entlen == 0) {
>>    		assert(retlen == 0);
>>    		entlen = strlen(ent);
>> @@ -430,7 +437,10 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
>>    			flow = DTRACEFLOW_NONE;
>>    	}
>>    
>> +#ifdef FIXME
>> +/* currently unused label */
>>    out:
>> +#endif
>>    	if (flow == DTRACEFLOW_ENTRY || flow == DTRACEFLOW_RETURN)
>>    		data->dtpda_prefix = str;
>>    	else
>> @@ -444,6 +454,7 @@ out:
>>    	return 0;
>>    }
>>    
>> +#if 0
>>    static int
>>    dt_nullprobe()
>>    {
>> @@ -455,6 +466,7 @@ dt_nullrec()
>>    {
>>    	return (DTRACE_CONSUME_NEXT);
>>    }
>> +#endif
>>    
>>    int
>>    dt_print_quantline(dtrace_hdl_t *dtp, FILE *fp, int64_t val,
>> @@ -968,6 +980,7 @@ dt_print_bytes(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr,
>>            return (dt_print_rawbytes(dtp, fp, addr, nbytes));
>>    }
>>    
>> +#if 0
>>    static int
>>    dt_print_tracemem(dtrace_hdl_t *dtp, FILE *fp, const dtrace_recdesc_t *rec,
>>        uint_t nrecs, const caddr_t buf)
>> @@ -1015,6 +1028,7 @@ dt_print_tracemem(dtrace_hdl_t *dtp, FILE *fp, const dtrace_recdesc_t *rec,
>>    
>>    	return (nconsumed);
>>    }
>> +#endif
>>    
>>    int
>>    dt_print_stack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
>> @@ -1423,6 +1437,7 @@ typedef struct dt_normal {
>>    	uint64_t dtnd_normal;
>>    } dt_normal_t;
>>    
>> +#if 0
>>    static int
>>    dt_normalize_agg(const dtrace_aggdata_t *aggdata, void *arg)
>>    {
>> @@ -1611,6 +1626,7 @@ dt_trunc(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
>>    
>>    	return (0);
>>    }
>> +#endif
>>    
>>    static int
>>    dt_print_datum(dtrace_hdl_t *dtp, FILE *fp, dtrace_recdesc_t *rec,
>> @@ -2360,6 +2376,10 @@ dt_consume_one(dtrace_hdl_t *dtp, FILE *fp, int cpu, char *buf,
>>    		epid = ((uint32_t *)data)[0];
>>    		tag = ((uint32_t *)data)[1];
>>    
>> +		/* FIXME: suppress compiler "unused variable" warning */
>> +		/* remove once tag is actually used */
>> +		assert(tag >= 0);
>> +
>>    		/*
>>    		 * Fill in the epid and address of the epid in the buffer.  We
>>    		 * need to pass this to the efunc.
>> @@ -2446,6 +2466,7 @@ dt_consume_one(dtrace_hdl_t *dtp, FILE *fp, int cpu, char *buf,
>>    
>>    		return done ? DTRACE_WORKSTATUS_DONE : DTRACE_WORKSTATUS_OKAY;
>>    	} else if (hdr->type == PERF_RECORD_LOST) {
>> +#ifdef FIXME
>>    		uint64_t	lost;
>>    
>>    		/*
>> @@ -2457,6 +2478,7 @@ dt_consume_one(dtrace_hdl_t *dtp, FILE *fp, int cpu, char *buf,
>>    		 * and data points to the 'id' member at this point.
>>    		 */
>>    		lost = *(uint64_t *)(data + sizeof(uint64_t));
>> +#endif
>>    
>>    		/* FIXME: To be implemented */
>>    		return DTRACE_WORKSTATUS_ERROR;
>> @@ -2557,6 +2579,7 @@ typedef struct dt_begin {
>>    	int dtbgn_beginonly;
>>    } dt_begin_t;
>>    
>> +#if 0
>>    static int
>>    dt_consume_begin_probe(const dtrace_probedata_t *data, void *arg)
>>    {
>> @@ -2751,6 +2774,7 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
>>    
>>    	return (rval);
>>    }
>> +#endif
>>    
>>    dtrace_workstatus_t
>>    dtrace_consume(dtrace_hdl_t *dtp, FILE *fp,
>> diff --git a/libdtrace/dt_dof.c b/libdtrace/dt_dof.c
>> index 090d6736..90eeb065 100644
>> --- a/libdtrace/dt_dof.c
>> +++ b/libdtrace/dt_dof.c
>> @@ -715,6 +715,14 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags)
>>    		}
>>    #else
>>    		i = 0;
>> +
>> +		/* suppress compiler warnings until FIXME */
>> +		ap = NULL;
>> +		assert(ap == NULL);
>> +		assert(fmt);
>> +		assert(next);
>> +		assert(sdp || sdp == NULL);
>> +		assert(strndx == 0);
>>    #endif
>>    
>>    		if (i > 0) {
>> diff --git a/libdtrace/dt_pid.c b/libdtrace/dt_pid.c
>> index 2d6e3a7c..67084aab 100644
>> --- a/libdtrace/dt_pid.c
>> +++ b/libdtrace/dt_pid.c
>> @@ -55,7 +55,7 @@ dt_pid_objname(Lmid_t lmid, const char *obj)
>>    	if (lmid == LM_ID_BASE)
>>    		return strdup(obj);
>>    
>> -	len = snprintf(NULL, INT_MAX, "LM%lx`%s", lmid, obj);
>> +	len = snprintf(NULL, 0, "LM%lx`%s", lmid, obj);
>>    	buf = malloc(len);
>>    	if (buf)
>>    		snprintf(buf, len, "LM%lx`%s", lmid, obj);
>> diff --git a/libdtrace/dt_subr.c b/libdtrace/dt_subr.c
>> index 39a2eefd..2b01f4eb 100644
>> --- a/libdtrace/dt_subr.c
>> +++ b/libdtrace/dt_subr.c
>> @@ -694,8 +694,6 @@ dt_zalloc(dtrace_hdl_t *dtp, size_t size)
>>    void *
>>    dt_calloc(dtrace_hdl_t *dtp, size_t cnt, size_t size)
>>    {
>> -	void *data;
>> -
>>    	if (cnt == 0 || size == 0)
>>    		return NULL;
>>    
>> diff --git a/libdtrace/dt_work.c b/libdtrace/dt_work.c
>> index 9b898b0a..bbe08886 100644
>> --- a/libdtrace/dt_work.c
>> +++ b/libdtrace/dt_work.c
>> @@ -173,9 +173,7 @@ dtrace_status(dtrace_hdl_t *dtp)
>>    int
>>    dtrace_go(dtrace_hdl_t *dtp)
>>    {
>> -	void	*dof;
>>    	size_t	size;
>> -	int	err;
>>    
>>    	if (dtp->dt_active)
>>    		return (dt_set_errno(dtp, EINVAL));
>> @@ -193,6 +191,7 @@ dtrace_go(dtrace_hdl_t *dtp)
>>    		return (-1); /* dt_errno has been set for us */
>>    
>>    #if 0
>> +	void	*dof;
>>    	if ((dof = dtrace_getopt_dof(dtp)) == NULL)
>>    		return (-1); /* dt_errno has been set for us */
>>    
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel




More information about the DTrace-devel mailing list