mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] profile: further Codying Style fixes, take 2
@ 2008-01-04 17:52 Paolo Ciarrocchi
  2008-01-04 20:37 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Ciarrocchi @ 2008-01-04 17:52 UTC (permalink / raw)
  To: Linux Kernel, sam, mingo

Further fixes to profile.c, checkpatch.pl now reports:

	total: 0 errors, 2 warnings, 601 lines checked

  WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
  #410: FILE: profile.c:410:
  +EXPORT_SYMBOL_GPL(profile_hits);
I cannot fix this without changing the funtionality in case of non-SMP build.


  WARNING: externs should be avoided in .c files
  #509: FILE: profile.c:509:
  +       extern int setup_profiling_timer(unsigned int multiplier);
I don't know what to do with this warning.

Compile tested, no change in the size of the .o file after
applying the patch.

paolo@paolo-desktop:/tmp$ size profile.o.*
   text    data     bss     dec     hex filename
   3718     144      12    3874     f22 profile.o.after
   3718     144      12    3874     f22 profile.o.before


Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
---
 kernel/profile.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/kernel/profile.c b/kernel/profile.c
index c99153b..e64c2da 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -125,7 +125,7 @@ void profile_task_exit(struct task_struct *task)
 	blocking_notifier_call_chain(&task_exit_notifier, 0, task);
 }
 
-int profile_handoff_task(struct task_struct * task)
+int profile_handoff_task(struct task_struct *task)
 {
 	int ret;
 	ret = atomic_notifier_call_chain(&task_free_notifier, 0, task);
@@ -141,11 +141,13 @@ int task_handoff_register(struct notifier_block *n)
 {
 	return atomic_notifier_chain_register(&task_free_notifier, n);
 }
+EXPORT_SYMBOL_GPL(task_handoff_register);
 
 int task_handoff_unregister(struct notifier_block *n)
 {
 	return atomic_notifier_chain_unregister(&task_free_notifier, n);
 }
+EXPORT_SYMBOL_GPL(task_handoff_unregister);
 
 int profile_event_register(enum profile_type type, struct notifier_block *n)
 {
@@ -164,7 +166,7 @@ int profile_event_register(enum profile_type type, struct notifier_block *n)
 
 	return err;
 }
-
+EXPORT_SYMBOL_GPL(profile_event_register);
 
 int profile_event_unregister(enum profile_type type, struct notifier_block *n)
 {
@@ -183,6 +185,7 @@ int profile_event_unregister(enum profile_type type, struct notifier_block *n)
 
 	return err;
 }
+EXPORT_SYMBOL_GPL(profile_event_unregister);
 
 int register_timer_hook(int (*hook)(struct pt_regs *))
 {
@@ -191,6 +194,7 @@ int register_timer_hook(int (*hook)(struct pt_regs *))
 	timer_hook = hook;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(register_timer_hook);
 
 void unregister_timer_hook(int (*hook)(struct pt_regs *))
 {
@@ -199,13 +203,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
 	/* make sure all CPUs see the NULL hook */
 	synchronize_sched();  /* Allow ongoing interrupts to complete. */
 }
-
-EXPORT_SYMBOL_GPL(register_timer_hook);
 EXPORT_SYMBOL_GPL(unregister_timer_hook);
-EXPORT_SYMBOL_GPL(task_handoff_register);
-EXPORT_SYMBOL_GPL(task_handoff_unregister);
-EXPORT_SYMBOL_GPL(profile_event_register);
-EXPORT_SYMBOL_GPL(profile_event_unregister);
 
 #endif /* CONFIG_PROFILING */
 
@@ -366,7 +364,7 @@ static int __devinit profile_cpu_callback(struct notifier_block *info,
 			per_cpu(cpu_profile_hits, cpu)[0] = page_address(page);
 		}
 		break;
-	out_free:
+out_free:
 		page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
 		per_cpu(cpu_profile_hits, cpu)[1] = NULL;
 		__free_page(page);
@@ -409,7 +407,6 @@ void profile_hits(int type, void *__pc, unsigned int nr_hits)
 	atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
 }
 #endif /* !CONFIG_SMP */
-
 EXPORT_SYMBOL_GPL(profile_hits);
 
 void profile_tick(int type)
@@ -427,7 +424,7 @@ void profile_tick(int type)
 #include <asm/uaccess.h>
 #include <asm/ptrace.h>
 
-static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
+static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
 			int count, int *eof, void *data)
 {
 	int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
@@ -437,8 +434,8 @@ static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
 	return len;
 }
 
-static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer,
-					unsigned long count, void *data)
+static int prof_cpu_mask_write_proc(struct file *file,
+	const char __user *buffer,  unsigned long count, void *data)
 {
 	cpumask_t *mask = (cpumask_t *)data;
 	unsigned long full_count = count, err;
@@ -457,7 +454,8 @@ void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
 	struct proc_dir_entry *entry;
 
 	/* create /proc/irq/prof_cpu_mask */
-	if (!(entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir)))
+	entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
+	if (!entry)
 		return;
 	entry->data = (void *)&prof_cpu_mask;
 	entry->read_proc = prof_cpu_mask_read_proc;
@@ -508,7 +506,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
 			     size_t count, loff_t *ppos)
 {
 #ifdef CONFIG_SMP
-	extern int setup_profiling_timer (unsigned int multiplier);
+	extern int setup_profiling_timer(unsigned int multiplier);
 
 	if (count == sizeof(int)) {
 		unsigned int multiplier;
@@ -591,7 +589,8 @@ static int __init create_proc_profile(void)
 		return 0;
 	if (create_hash_tables())
 		return -1;
-	if (!(entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL)))
+	entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL);
+	if (!entry)
 		return 0;
 	entry->proc_fops = &proc_profile_operations;
 	entry->size = (1+prof_len) * sizeof(atomic_t);
-- 
1.5.4.rc2.17.g257f


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

* Re: [PATCH] profile: further Codying Style fixes, take 2
  2008-01-04 17:52 [PATCH] profile: further Codying Style fixes, take 2 Paolo Ciarrocchi
@ 2008-01-04 20:37 ` Sam Ravnborg
  2008-01-05  0:18   ` Paolo Ciarrocchi
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2008-01-04 20:37 UTC (permalink / raw)
  To: Paolo Ciarrocchi; +Cc: Linux Kernel, mingo

On Fri, Jan 04, 2008 at 06:52:09PM +0100, Paolo Ciarrocchi wrote:
> Further fixes to profile.c, checkpatch.pl now reports:
> 
> 	total: 0 errors, 2 warnings, 601 lines checked
> 
>   WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
>   #410: FILE: profile.c:410:
>   +EXPORT_SYMBOL_GPL(profile_hits);
> I cannot fix this without changing the funtionality in case of non-SMP build.

If you look a bit more you will see two functions named
profile_hits.
So you just add the export twice - like this:
diff --git a/kernel/profile.c b/kernel/profile.c
index 5e95330..fc4570d 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -337,6 +337,7 @@ out:
        local_irq_restore(flags);
        put_cpu();
 }
+EXPORT_SYMBOL_GPL(profile_hits);

 static int __devinit profile_cpu_callback(struct notifier_block *info,
                                        unsigned long action, void *__cpu)
@@ -408,9 +409,8 @@ void profile_hits(int type, void *__pc, unsigned int nr_hits)
        pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
        atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
 }
-#endif /* !CONFIG_SMP */
-
 EXPORT_SYMBOL_GPL(profile_hits);
+#endif /* !CONFIG_SMP */

 void profile_tick(int type)
 {

Which has the added benefit that it is now documented for
both implementations that they are exported.

> 
> 
>   WARNING: externs should be avoided in .c files
>   #509: FILE: profile.c:509:
>   +       extern int setup_profiling_timer(unsigned int multiplier);
> I don't know what to do with this warning.

Stick the prototype in profile.h maybe?
I can see that not all implementers of this function
includes profile.h so it is not foolproof.

	Sam

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

* Re: [PATCH] profile: further Codying Style fixes, take 2
  2008-01-04 20:37 ` Sam Ravnborg
@ 2008-01-05  0:18   ` Paolo Ciarrocchi
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Ciarrocchi @ 2008-01-05  0:18 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Linux Kernel, mingo

On Jan 4, 2008 9:37 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Fri, Jan 04, 2008 at 06:52:09PM +0100, Paolo Ciarrocchi wrote:
> > Further fixes to profile.c, checkpatch.pl now reports:
> >
> >       total: 0 errors, 2 warnings, 601 lines checked
> >
> >   WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> >   #410: FILE: profile.c:410:
> >   +EXPORT_SYMBOL_GPL(profile_hits);
> > I cannot fix this without changing the funtionality in case of non-SMP build.
>
> If you look a bit more you will see two functions named
> profile_hits.
> So you just add the export twice - like this:
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 5e95330..fc4570d 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -337,6 +337,7 @@ out:
>         local_irq_restore(flags);
>         put_cpu();
>  }
> +EXPORT_SYMBOL_GPL(profile_hits);
>
>  static int __devinit profile_cpu_callback(struct notifier_block *info,
>                                         unsigned long action, void *__cpu)
> @@ -408,9 +409,8 @@ void profile_hits(int type, void *__pc, unsigned int nr_hits)
>         pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
>         atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
>  }
> -#endif /* !CONFIG_SMP */
> -
>  EXPORT_SYMBOL_GPL(profile_hits);
> +#endif /* !CONFIG_SMP */
>
>  void profile_tick(int type)
>  {
>
> Which has the added benefit that it is now documented for
> both implementations that they are exported.

Nice, thanks for the explanation Sam.

> >
> >
> >   WARNING: externs should be avoided in .c files
> >   #509: FILE: profile.c:509:
> >   +       extern int setup_profiling_timer(unsigned int multiplier);
> > I don't know what to do with this warning.
>
> Stick the prototype in profile.h maybe?
> I can see that not all implementers of this function
> includes profile.h so it is not foolproof.

That would not be an easy fix for me (I'm almost new to these things),
I can try to that but I would appreciated if Ingo could apply the patch
as it is now and wait a bit for the further fix.

Ingo, do you agree?


Ciao,
-- 
Paolo
http://paolo.ciarrocchi.googlepages.com/

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

end of thread, other threads:[~2008-01-05  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-04 17:52 [PATCH] profile: further Codying Style fixes, take 2 Paolo Ciarrocchi
2008-01-04 20:37 ` Sam Ravnborg
2008-01-05  0:18   ` Paolo Ciarrocchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®