Skip to contentSkip to conversation

trace_osnoise: rename main to trace_main to avoid Werror=main

PATCH NAK Jackie Liu 2 participants 3 messages Sep 6, 2021

Subsystems (2)
lore
Share & tools
lore

Jackie Liu

author
#0 lore raw

PATCH 1/1 trace_osnoise: rename main to trace_main to avoid Werror=main

From: Jackie Liu <[email protected]>

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 <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace_osnoise.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_osnoise.c +3 -3
index b61eefe5ccf5..938e2791010a 100644
@@ -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");
Signature · 1 line
2.25.1
maintainer NAK
#1 lore raw
Quoted 6 lines · On Mon, 6 Sep 2021 17:40:03 +0800 Jackie Liu <[email protected]> wrote:

From: Jackie Liu <[email protected]>

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/[email protected]/

-- Steve

Quoted 37 lines
Fixes a955d7eac177 ("trace: Add timerlat tracer")
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace_osnoise.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_osnoise.c +3 -3
index b61eefe5ccf5..938e2791010a 100644
@@ -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");
author
#2 lore raw

Hi Steven. Thank you for let me know.

--
Jackie Liu

September 6, 2021 7:56 PM, "Steven Rostedt" <[email protected]> 写到:

Quoted 62 lines
Quoted 6 lines · On Mon, 6 Sep 2021 17:40:03 +0800 Jackie Liu <[email protected]> wrote:

From: Jackie Liu <[email protected]>

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/[email protected]

-- Steve

Quoted 36 lines
Fixes a955d7eac177 ("trace: Add timerlat tracer")
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>

---
kernel/trace/trace_osnoise.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_osnoise.c +3 -3
index b61eefe5ccf5..938e2791010a 100644
@@ -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");