All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace_osnoise: rename main to trace_main to avoid Werror=main
@ 2021-09-06  9:40 Jackie Liu
  2021-09-06 11:56 ` Steven Rostedt
  2021-09-06 13:17 ` Jackie Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Jackie Liu @ 2021-09-06  9:40 UTC (permalink / raw)
  To: rostedt, mingo; +Cc: linux-kernel, liu.yun

From: Jackie Liu <liuyun01@kylinos.cn>

kernel builds with -Werror=main, gcc report failed.

Avoids warnings like:
kernel/trace/trace_osnoise.c:1515:8: error: ‘main’ is usually a function [-Werror=main]

Fixes: a955d7eac177 ("trace: Add timerlat tracer")
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 kernel/trace/trace_osnoise.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index b61eefe5ccf5..938e2791010a 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1512,20 +1512,20 @@ static void stop_per_cpu_kthreads(void)
 static int start_kthread(unsigned int cpu)
 {
 	struct task_struct *kthread;
-	void *main = osnoise_main;
+	void *trace_main = osnoise_main;
 	char comm[24];
 
 #ifdef CONFIG_TIMERLAT_TRACER
 	if (osnoise_data.timerlat_tracer) {
 		snprintf(comm, 24, "timerlat/%d", cpu);
-		main = timerlat_main;
+		trace_main = timerlat_main;
 	} else {
 		snprintf(comm, 24, "osnoise/%d", cpu);
 	}
 #else
 	snprintf(comm, 24, "osnoise/%d", cpu);
 #endif
-	kthread = kthread_create_on_cpu(main, NULL, cpu, comm);
+	kthread = kthread_create_on_cpu(trace_main, NULL, cpu, comm);
 
 	if (IS_ERR(kthread)) {
 		pr_err(BANNER "could not start sampling thread\n");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] trace_osnoise: rename main to trace_main to avoid Werror=main
  2021-09-06  9:40 [PATCH] trace_osnoise: rename main to trace_main to avoid Werror=main Jackie Liu
@ 2021-09-06 11:56 ` Steven Rostedt
  2021-09-06 13:17 ` Jackie Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2021-09-06 11:56 UTC (permalink / raw)
  To: Jackie Liu; +Cc: mingo, linux-kernel

On Mon,  6 Sep 2021 17:40:03 +0800
Jackie Liu <liu.yun@linux.dev> wrote:

> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> kernel builds with -Werror=main, gcc report failed.
> 
> Avoids warnings like:
> kernel/trace/trace_osnoise.c:1515:8: error: ‘main’ is usually a function [-Werror=main]

NACK!

It's a stupid warning, and likely a bug in the compiler.

There's nothing wrong with using "main" as a local variable. It will
*never* conflict with the main main. Less so in the kernel, as the
kernel doesn't even have a main!

Do not send patches to fix this "error".

Not to mention, we already went through this discussion a month ago.

  https://lore.kernel.org/all/20210813224131.25803-1-rdunlap@infradead.org/

-- Steve

> 
> Fixes: a955d7eac177 ("trace: Add timerlat tracer")
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>  kernel/trace/trace_osnoise.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index b61eefe5ccf5..938e2791010a 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -1512,20 +1512,20 @@ static void stop_per_cpu_kthreads(void)
>  static int start_kthread(unsigned int cpu)
>  {
>  	struct task_struct *kthread;
> -	void *main = osnoise_main;
> +	void *trace_main = osnoise_main;
>  	char comm[24];
>  
>  #ifdef CONFIG_TIMERLAT_TRACER
>  	if (osnoise_data.timerlat_tracer) {
>  		snprintf(comm, 24, "timerlat/%d", cpu);
> -		main = timerlat_main;
> +		trace_main = timerlat_main;
>  	} else {
>  		snprintf(comm, 24, "osnoise/%d", cpu);
>  	}
>  #else
>  	snprintf(comm, 24, "osnoise/%d", cpu);
>  #endif
> -	kthread = kthread_create_on_cpu(main, NULL, cpu, comm);
> +	kthread = kthread_create_on_cpu(trace_main, NULL, cpu, comm);
>  
>  	if (IS_ERR(kthread)) {
>  		pr_err(BANNER "could not start sampling thread\n");


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] trace_osnoise: rename main to trace_main to avoid Werror=main
  2021-09-06  9:40 [PATCH] trace_osnoise: rename main to trace_main to avoid Werror=main Jackie Liu
  2021-09-06 11:56 ` Steven Rostedt
@ 2021-09-06 13:17 ` Jackie Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Jackie Liu @ 2021-09-06 13:17 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: mingo, linux-kernel

Hi Steven. Thank you for let me know.

--
Jackie Liu



September 6, 2021 7:56 PM, "Steven Rostedt" <rostedt@goodmis.org> 写到:

> On Mon, 6 Sep 2021 17:40:03 +0800
> Jackie Liu <liu.yun@linux.dev> wrote:
> 
>> From: Jackie Liu <liuyun01@kylinos.cn>
>> 
>> kernel builds with -Werror=main, gcc report failed.
>> 
>> Avoids warnings like:
>> kernel/trace/trace_osnoise.c:1515:8: error: ‘main’ is usually a function [-Werror=main]
> 
> NACK!
> 
> It's a stupid warning, and likely a bug in the compiler.
> 
> There's nothing wrong with using "main" as a local variable. It will
> *never* conflict with the main main. Less so in the kernel, as the
> kernel doesn't even have a main!
> 
> Do not send patches to fix this "error".
> 
> Not to mention, we already went through this discussion a month ago.
> 
> https://lore.kernel.org/all/20210813224131.25803-1-rdunlap@infradead.org
> 
> -- Steve
> 
>> Fixes: a955d7eac177 ("trace: Add timerlat tracer")
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
>> ---
>> kernel/trace/trace_osnoise.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
>> index b61eefe5ccf5..938e2791010a 100644
>> --- a/kernel/trace/trace_osnoise.c
>> +++ b/kernel/trace/trace_osnoise.c
>> @@ -1512,20 +1512,20 @@ static void stop_per_cpu_kthreads(void)
>> static int start_kthread(unsigned int cpu)
>> {
>> struct task_struct *kthread;
>> - void *main = osnoise_main;
>> + void *trace_main = osnoise_main;
>> char comm[24];
>> 
>> #ifdef CONFIG_TIMERLAT_TRACER
>> if (osnoise_data.timerlat_tracer) {
>> snprintf(comm, 24, "timerlat/%d", cpu);
>> - main = timerlat_main;
>> + trace_main = timerlat_main;
>> } else {
>> snprintf(comm, 24, "osnoise/%d", cpu);
>> }
>> #else
>> snprintf(comm, 24, "osnoise/%d", cpu);
>> #endif
>> - kthread = kthread_create_on_cpu(main, NULL, cpu, comm);
>> + kthread = kthread_create_on_cpu(trace_main, NULL, cpu, comm);
>> 
>> if (IS_ERR(kthread)) {
>> pr_err(BANNER "could not start sampling thread\n");

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-06 13:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06  9:40 [PATCH] trace_osnoise: rename main to trace_main to avoid Werror=main Jackie Liu
2021-09-06 11:56 ` Steven Rostedt
2021-09-06 13:17 ` Jackie Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.