Re: [PATCH] kernel/trace/trace.c: Switch the related code with CONFIG_TRACER_MAX_TRACE

From: Steven Rostedt
Date: Tue Nov 10 2015 - 11:40:09 EST


On Tue, 10 Nov 2015 05:21:16 +0800
Chen Gang <xili_gchen_5257@xxxxxxxxxxx> wrote:

> >From 0af9ca7a33b977d92498d990cb6f2a326dbad4f8 Mon Sep 17 00:00:00 2001
> From: Chen Gang <gang.chen.5i5j@xxxxxxxxx>
> Date: Tue, 10 Nov 2015 05:15:15 +0800
> Subject: [PATCH] kernel/trace/trace.c: Switch the related code with
> ÂCONFIG_TRACER_MAX_TRACE
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> tracing_max_lat_fops is used only when TRACER_MAX_TRACE enabled, so also
> swith the related code. The related warning with defconfig under x86_64:
>
> Â Â CC Â Â Âkernel/trace/trace.o
> Â kernel/trace/trace.c:5466:37: warning: âtracing_max_lat_fopsâ defined but not used [-Wunused-const-variable]
> Â Âstatic const struct file_operations tracing_max_lat_fops = {

I'm curious to what compiler are you using? Because, for me gcc simply
compiles it out without any warning or anything because it's labeled as
a constant.

I'm not against the patch, but I simply don't get this warning. If I
remove the "const" then I do.

-- Steve

>
> Signed-off-by: Chen Gang <gang.chen.5i5j@xxxxxxxxx>
> ---
> Âkernel/trace/trace.c | 6 ++++++
> Â1 file changed, 6 insertions(+)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index b115826..87fb980 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -4548,6 +4548,8 @@ out:
> Â return ret;
> Â}
> Â
> +#ifdef CONFIG_TRACER_MAX_TRACE
> +
> Âstatic ssize_t
> Âtracing_max_lat_read(struct file *filp, char __user *ubuf,
> Â Â Â size_t cnt, loff_t *ppos)
> @@ -4562,6 +4564,8 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
> Â return tracing_nsecs_write(filp->private_data, ubuf, cnt, ppos);
> Â}
> Â
> +#endif
> +
> Âstatic int tracing_open_pipe(struct inode *inode, struct file *filp)
> Â{
> Â struct trace_array *tr = inode->i_private;
> @@ -5463,12 +5467,14 @@ static const struct file_operations tracing_thresh_fops = {
> Â .llseek = generic_file_llseek,
> Â};
> Â
> +#ifdef CONFIG_TRACER_MAX_TRACE
> Âstatic const struct file_operations tracing_max_lat_fops = {
> Â .open = tracing_open_generic,
> Â .read = tracing_max_lat_read,
> Â .write = tracing_max_lat_write,
> Â .llseek = generic_file_llseek,
> Â};
> +#endif
> Â
> Âstatic const struct file_operations set_tracer_fops = {
> Â .open = tracing_open_generic,
> --Â
> 1.9.3
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/